Monthly Archives: May 2011

mkvmerge + mplayer Sadness Fix

I have been having some issues with newer versions of mkvmerge creating files that make mplayer cry. I finally messed around with the options enough to discover what (I think) was the problem. Header compression reduces filesizes of attachments significantly, but there are some compatibility problems with the files that have this option enabled. Here’s what I finally ended up with:

mkvmerge -o video.mkv --default-language eng \
  --compression -1:none --default-duration 0:41.708ms \
  --nalu-size-length 0:4 -A video.264 --compression -1:none \
   audio.dts subs.srt

Note that this doesn’t set the output language for the audio and subtitle tracks, but there’s only one of each, so I don’t really care. The key point is since this is an elementary h264 stream, I have to set the default-duration and nalu-size-length options manually, since they’re not encoded into the file. This default-duration corresponds to a 23.976fps frame rate, so you have to convert according to your source.

Really, the header compression option should be disabled by default; I have no idea why it’s on. It does save about 30MB of space in the output file, but that’s moot if it ruins compatibility.