July 11th, 2006

display

The secrets of MKVs and H.624 revealed!

As I posted earlier, the MACH F is having trouble with playing H.624 encoded video content (often in a MKV or MP4 container). XviD works like a charm though -- no problems with that.
I have been told that you can achieve higher quality video in H.624 with the same file size, and while that is all fine and dandy, the added overhead of separate audio and subtitling streams make the filesize actually larger than the same video encoded with XviD/MP3, with static subtitles.

Sure, being able to switch off the subtitles is great -- except that I don't understand Japanese well enough to do without the subtitles. I need those subtitles.
Switching the audio stream is great too -- if I wanted to watch a dubbed DVD rip, which I don't. And only a single audio stream bloats the file anyway!
Oh, and I can't even play the content anyway, so thanks but no thanks anyway.

However, sometimes you just don't have a choice if you want to catch those episodes of your favourite fansub. So what to do? Well, re-encode the video to use XviD/MP3, of course! Surely that is a worthy use of those hyperthreaded gigahertzes available to me!

Except that this one file has had me stumped for weeks. No matter what I did, I could not get the audio and video to sync up. The audio was perfectly in sync with the subtitles, but the video always ran a bit before the audio. I calculated the framerates that should be correct, but that didn't work either.

Today I found out that the MKV-container supports variable framerates. WTF is up with that -- what is the use of variable framerates in a file format that works with keyframes and delta-frames anyway?
Apparently someone thought it was a good idea to introduce variable framerates -- and while AviSynth produced 23.976 frames per second, the skipped frames were served before their time had come, which resulted in the video moving faster than the audio.
I had to upgrade to version 2.5.6 to be able to use the 'convertfps' parameter of DirectShowSource, which inserts frames to get a constant framerate.

And now it works. Which is cool, because now I can convert those unplayable files into something manageble. And the re-coded AVI file is 136MB smaller than the original MKV file to boot!