The Matroska container format for video has become popular over the last few years because it merges a number of good ideas and let’s a single file contain multiple video, audio and subtitle streams. No longer do you have to keep multiple .vob/.mpg/.avi.mp4, and multiple .sub/.srt/.idx files to have 3 different audio and subtitles. All of them can be placed into a single .mkv file. For me having the subtitles efficiently contained inside the same file is good, but the real, fantastic reason that MKV containers are brilliant is you can easily correct aspect ratio issues without re-encoding.
Here’s another article for why you should also use MKV if you’d like more specifics.
There’s another nice bonus. In my testing, the .mkv files are always smaller than the .avi files from which they are made.
Jumping into the How-To
First, you’ll need to install the MKVToolNix using your package manager and repositories. On my Lubuntu system, that was just
sudo apt-get install mkvtoolnix
I use Linux, but the mkv tools are cross platform. There’s even a GUI for people that demand it.
Let’s suppose you have a few files.
- FILE.avi (xvid video + mp3 audio in an AVI container)
- FILE.srt (Text subtitles) and
- FILE.idx (PS subtitles – may contain multiple languages)
To convert the AVI file into an MKV file, simply use
mkvmerge -o FILE.mkv FILE.avi
To convert the AVI file into an MKV file with SRT subtitles, simply use
mkvmerge -o FILE.mkv FILE.avi FILE.srt
If you’d like to label the language for the subtitles, that open exists. Check the man page.
To convert the AVI file into an MKV file with PS subtitles, simply use
mkvmerge -o FILE.mkv FILE.avi FILE.idx
To Correct the Aspect Ratio, simply use
mkvmerge --aspect-ratio '1:4/3' -o FILE.fix.mkv FILE.mkv
where ‘1’ is the video stream number and ‘4/3’ is the desired aspect ratio for display. Note that this only seems to work when the inputfile is already inside an MKV container.
I only show AVI/xvid files in these examples, but MPEG2 and MPEG4 files will work exactly the same. The MKV is a smart container, so it won’t let you put unsupported video, audio or subtitles into the container. It is also FAST, about the speed of a file copy, which makes sense because the tool isn’t doing much more than building a small XML file containing the metadata for the different streams, then zlib compressing it, and shoving everything into a file with .mkv at the end. I’m certain that I’ve over simplified what it really happening, but it is still FAST.
The ease for these sample commands show the simplicity of the MKV container. I’m sold on them now that I own a network media player that knows how to deal with them, the WD TV-Live. VLC and mplayer will both playback these files and subtitles too.
Win7 Media Center doesn’t appear to support the MKV format out of the box. Here’s an article on how to convince 7MC to support MKV. I expect their instructions will work, but have not tried them yet.
Use the following link to trackback from your own site: