Tag Archives: encoding

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.


Extracting M2TS length from a BDMV directory in Linux

I was having the hardest time getting various programs to echo the runtime of m2ts files in Linux, and it turns out someone wrote a parser for the files in the BDMV/PLAYLIST directory, which have all of this information.

  • Get bdtools. I got Version 1.4. You can find it here.
  • ./configure && make && sudo make install
  • Try running mpls_dump. I got this error when running:
    mpls_dump: error while loading shared libraries: libbd-1.0.so.1: cannot open shared object file: 
    No such file or directory

  • To fix it, do this:
    echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf
    sudo ldconfig