Monday, April 09, 2012

Small Victories

With the proliferation of devices in the house that are capable of playing video files, as well as the lack of a TV in my exercise area, recently I decided to undertake a project of converting all our DVDs into MPEG-4 videos. It is somewhat like a crazy flashback to circa-1999/2000 when I converted all my CDs into MP3s. All the hallmarks are there.

The tantalizing prospect of technology that almost does what you want it to do. The need to have a workflow of several programs working in concert to really convert things correctly. All you young whippersnappers probably don't even remember when ripping a CD required a whole separate program rather, and getting track titles/cover art was an adventure in itself. That's pretty much what mass converting DVDs is like these days.

Anyways, the process has been going reasonably well and I'd gotten through about a third of our DVDs. Emboldened by my success, however, I fell prey to thinking that the only right way to convert The Godfather: Part II's two discs was by combining the two resultant files. I mean, having two files is just a relic of limited storage media. As soon as we're talking video files there is no reason you shouldn't just be able to merge those files together and make a single 3 hour 20 minute file with the whole movie the way it was meant to be viewed.

Oh, how silly.

It turns out that, despite the deceptive simplicity, this is nearly impossible. The Internet is rife with programs claiming the ability to do this, and even more forum posts from joker #1 claiming program Y was able to do it, and joker #2 claiming that it didn't work for his videos, and shill #1 advocating for a paid program that is just a thin wrapper around GPL software.

Over the past three or four days I tried every suggestion, half-baked scheme, or sequence of multiple programs to no avail. Some of the programs came frustratingly close. Able to merge the m4v files successfully, but re-encoding the video and thus wrecking the quality, able to preserve the quality of the video but splicing the audio tracks on-top of each other so you hear both halves of the movie in the first half and silence in the second, misaligned audio, or just straight-up producing corrupt files.

Yesterday evening I was ready to admit defeat and import the two individual video files, when I realized there was one dark alley even I had not been desperate enough to travel down: MKV containers. If you are familiar with the nerdier corners of the internet, you might have heard of it, but suffice to say up to this point it's been relegated over to the 'technically superior but basically unsupported by real devices and thus impractical' corner of the video world.

But in my desperation, I went there, and much to my pleasant surprise tonight I was able to use MKV as a waypoint to support the merging before converting things back to m4v. The actual process involved some trial and error, but in the end accomplished everything I wanted done and I am now the proud owner of a perfect-appearing single complete Godfather: Part 2 video file.

In case you are silly enough to follow me down this path, here was the process:

  1. Ripped the DVDs to the computer as normal
  2. Converted the DVDs with Handbrake as normal except selected MKV containers instead of MP4
  3. Used mkvmerge (GUI) to add the first MKV file and append the second MKV file into a new combined MKV
  4. Used mkvmerge (GUI)to load the chapters from the combined file, rename the last 14 chapters to be numbered sequentially after the first MKV file's 16 chapters, and write the new chapter 1-30 back into the combined file
  5. Used Yamb unsuccessfully to convert the MKV file to MP4, but used the command-line's it generated for the next two steps
  6. Manually ran mkvextract to extract the three tracks (one video, two audio) from the combined MKV. This was required because Yamb was using the mkvinfo 1-3 track numbering while mkvextract wants 0-2
  7. Manually ran mp4box to mux the three tracks into a new MP4 file. This was required because the syntax Yamb generated for the -par parameter was incorrect and :par=40:33 needed to be appended onto the -add for track 1 rather than being a separate argument.
  8. Imported the new MP4 into iTunes as normal

And that, dear reader, is what passes for 'easy' in Internet Video Nerd land. Luckily I am very capable of deriving satisfaction from that sort of triumph over technology. So now it's time to go back and re-do my LOTR extended edition files into the three four-hour behemoths Peter Jackson intended.
Read the whole post.