Skip to content

MKVToolNix for Mere Mortals

A film on a computer is rarely one thing. It is a picture track, one or more soundtracks, subtitles, chapter marks and labels, all packed into a single file — the container. Most tools that touch such a file want to re-encode it: decode every frame and encode it again, slowly, losing a little quality on the way. MKVToolNix does the other job. It is a set of tools for the Matroska container (the .mkv file) that rearranges what is already there — merging picture, sound and subtitles into one file, renaming tracks, splitting a file into pieces, taking a track back out — without decoding a single frame. The picture and sound come out bit for bit the ones that went in.

This guide teaches the four command-line tools — mkvmerge, mkvinfo, mkvpropedit and mkvextract — by building one small sample film and then taking it apart again. The film is synthetic on purpose: twelve seconds of test-pattern video, two sine tones standing in for soundtracks, and three subtitle lines about a lighthouse keeper, all generated by ffmpeg in the lab. Nothing in it is recorded material, so every number can be checked and every step repeated exactly.

The lab behind this guide ran the real thing: MKVToolNix 82.0, installed from the Ubuntu package, driven entirely from the command line. Against the sample film it merged four sources into one MKV, read the result three ways (a structured tree, a plain summary and JSON for scripts), rewrote the file's title and track flags in place, split the film by duration and by size, joined the pieces back together — and measured what the join did to the running time, because the honest answer is not "nothing". It added chapters, tags and a poster attachment, extracted all three back out and compared checksums, and deliberately broke things seven ways: missing files, wrong track numbers, a codec mismatch on append, the famous missing plus sign, and a truncated file that every tool insisted was fine while holding only 4 of its 120 frames.

What the lab could not do, it did not fake. The graphical program, mkvtoolnix-gui, needs a screen the lab does not have, so it is described from the documentation and labelled as such. Re-encoding — changing the picture or sound themselves — is a different tool's job entirely, and chapter 11 says which tools those are.

One property of this toolbox deserves saying early, because it cuts both ways. A Matroska file carries metadata: titles, tag names and values, the application that wrote it, statistics about every track. That is what makes the file pleasant to use — and it travels with the file when you share it. Chapter 9 shows exactly what a file can say about where it has been, and how to look before you pass one on. Work on media you have the right to rearrange; MKVToolNix itself cannot decrypt or unlock anything, and this guide never asks it to.

What this guide covers

  • What MKVToolNix is — the container idea: tracks in a box, rearranged without re-encoding, and what that buys and costs
  • The moving parts — the four tools and the parts of a Matroska file they each touch: tracks, the segment information, chapters, tags and attachments
  • Installing MKVToolNix — the apt package, the four version checks, and a word about the GUI package this guide does not run
  • Your first merge — picture, two soundtracks and subtitles into one MKV, with titles and languages set as it is built
  • Reading an MKV — mkvinfo's tree, the one-line summary, and mkvmerge's JSON identification that scripts can rely on
  • Fixing the labels — mkvpropedit rewrites the title, track names, languages and the default and forced flags in place, in a second, without remuxing
  • Splitting and joining — cutting a file by duration or size, appending files end to end, and the measured surprise in the joined file's running time
  • Extracting tracks — mkvextract pulls tracks back out as raw streams and subtitle files, and the checks that prove they survived
  • Chapters, tags and attachments — adding all three with mkvpropedit, reading the tags a file inherited without being asked, and extracting everything back for comparison
  • Recipes — add a subtitle track to a finished film, choose the soundtrack a player starts with, cut a long recording into sending-size pieces, and audit a file's metadata before sharing it
  • The neighbours — ffmpeg the re-encoder, HandBrake, VLC, Avidemux and MP4Box: what each does that MKVToolNix doesn't, and vice versa
  • Limits — no re-encoding ever, strict rules for appending, keyframe-bound splits, joins that do not rebuild the original exactly, and readers too polite to notice a truncated file
  • Troubleshooting — the errors from the lab, word for word, with what each one means and the check that catches the failures no error message reports
  • Glossary — the terms, collected in one place

What it doesn't cover

Changing the media itself — shrinking a file by quality, converting formats, filtering picture or sound. That is re-encoding, and it belongs to ffmpeg and HandBrake; this toolbox never does it, on purpose. Making MKV files play is a player's job, not covered beyond the checks a player would rely on. The graphical MKVToolNix GUI is described but not driven, for the reason given above. And files protected by DRM are out of scope in both senses: the tools here cannot open them, and nothing in this guide is about defeating that.

How to use this guide

Read chapter 1 for the model and chapter 2 before installing — knowing which tool touches which part of the file turns later surprises into named problems. Chapters 3 to 5 give you the tools and a merged file in one sitting. Chapter 6 is the quiet superpower: most real-world MKV work is fixing labels on files that already exist, and it takes seconds. Chapter 7's split and join measurements are worth reading before you trust either on something long. The lab's transcripts live in mkvtoolnix-lab/transcripts/; its fixture generator is mkvtoolnix-lab/make-fixtures.sh, its subtitle, chapter and tag fixtures sit beside it, and its measuring script is mkvtoolnix-lab/track-table.py.


Part of the series

This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.

Related guides:

License

The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.