More geekery. Today’s fun centered around videos and trying to get the damned things to play. The good songs DVD is part of a larger project to send a bunch of stuff off to Mauritania. Another bit of that is a couple DVDs, one with Scrubs and another with Coupling.
Through the magic of BitTorrent, I have all the episodes of both, but Coupling will only play in Xine. This isn’t a huge problem for me since I’m a geek and have Xine on my Linux box. It is a problem though for the non-geek people I’m sending this to. So, I needed to fix it. The only problem is I know diddly about video stuff.
Well, the file extensions are mkv, so I started there. It turns out that mkv stands for “Matroska video.” When you watch a video on your computer you are not just watching, you are listening as well. The computer needs information about how the audio and the video sync up in order to play correctly. Matroska is a format to describe that. Another container format that I’m sure most everyone has seen is Microsoft‘s avi format.
In looking on the Matroska site, VLC is one of their recommended players and MPlayer is supported as well and neither works. So, more digging is in order…
I found some tools for manipulating mkvs, and
mkvinfo let me know that my files contained an Ogg Vorbis sound stream and a H.264/MPEG-4 AVC video stream. (Matroska looks to be a pretty intriguing format, supporting things like multiple audio channels and subtitles.)
This was interesting as as H.264 is pretty new and the only place I’ve seen it so far is in IPTV podcasting on hacker sites like Hak5 and FTS. I was pretty sure this was where the problem since Ogg is old.
Well, I wandered the internet trying to find someone else having a similar problem, but to no avail. So then I decided to reencode the files. If you’ve ever seen Multiplicity, you are familiar with the “copy of a copy” principle. Every time, some data is lost and you never do anything but get further from the original. I was pretty much stymied, so I figured I’d bite the bullet.
None of the tools on my Fedora Core 4 machine could encode H.264, so I decided instead to encode to MPEG-4. It took me a bit to figure out how to get FFmpeg to do it, but eventually, I got it working.
Lesson #1. Encoding video takes for freaking ever. The MPEG encoding is a two pass process where the first pass collect some statistics and the second uses those to encode the file. These episodes of Coupling and about 50 minutes and 688px x 400px. On my 1.7gHz processor it takes about 25 minutes per pass.
Lesson #2. Whoever created these files did some magic. The original file, which looks really good, is 205mb. My MPEG-4 was over 400. This is not an acceptable increase. If I hadn’t seen how little they could be, I’d probably accept it since I expect a two hour movie to be around 1.5gb. Since I know it is possible to do it in less space though, I am bound and determined to match that.
I’m currently running the video through x264 to see if I can’t get some better compression. In this one each pass takes about an hour and a half, so I’ve got some waiting yet to do. I’ll post the result.