Monday, March 21, 2011

Ripping DVDs

Since getting a Cisco/Linksys E3000 router running with a MiniDLNA server (via TomatoUSB), I’ve decided to start ripping our DVD collection into a format that can be played on:
  • TiVo HD (pushed via pyTivo or MiniDLNA)
  • iPhone 4
  • AppleTV 2
The commonly supported formats are MPEG2 and h.264; I’m opting for h.264 for the better compression even though it means that I lose subtitle support on the TiVo HD (maybe an update will fix it, right?).
Since others may want to replicate my work, here is my process:

1. Ripping

I’m using Windows 7 (64-bit), so unfortunately, DVD43 is not an option.  Therefore the first step is to rip the DVD to remove the copy protection.  I’ve been using the free DVD Decrypter to copy the disc to my hard drive.

2. Encoding

Handbrake gets me most of the way done; it’s a great (almost) single-step process.  Here are my notes on dealing with the TiVo HD, using the streambaby video compatibility page as a starting point:
  • checking “Web Optimized” seems to do the same thing as MP4 FastStart or qt-faststart, though I’m not positive
  • when using h.264, if the framerate is variable and/or under 25fps, the TiVo will stutter and it won’t play right.  Force the FPS to 29.97
  • I’ve found RF:18 to be a good quality setting; movies end up at about 2GB for a 2:30 hour movie.
  • I’m not sure exactly what the problem with the audio is, but when I use AC3 passthrough (on my Harry Potter DVDs, at least), the TiVo reboots itself the second the video is pushed to it.  It could be that the audio sample rate is wrong or it’s VBR or something, so I set it to AC3 (ffmpeg) with a 48 sample rate and 160 bitrate.
I’ve created a HandBrake preset file (tivo.plist) to deal with these problems.  It was made for version 0.9.5.
My process is thus:
  • set the preset to TiVo HD
  • add the Closed Caption track (more on the difficulties with that track later).  I haven’t tried more than one track.
  • add chapter markers and import the chapter names via ChapterGrabber.  Unfortunately, ChapterGrabber doesn’t save in the csv format used by HandBrake, so I save as a .chapters file and use a perl script ( to change the format.
  • Encode.  It runs at about 10-15fps, so a 2:30 movie takes about 5 hours.

3. TiVo Fixes

At this point, the file can be pushed to the TiVo, but the first few seconds will be green and blocky.  After searching a while, I found that the problem is that the audio track needs to be before the video track.  I’m not sure why, but it does fix it.  So my process is:
  • run a MP4box (download here) command to fix the video:
    mp4box dest.mp4 -add "source.m4v#2" -add "source.m4v#1" -add "source.m4v#3" -add "source.m4v#4" 
    (#1 is the video stream, #2 the audio, #3 is the subtitle stream and #4 is the chapter stream; use "mp4box -std -info source.m4v" to list the streams)
  • use MetaGenerator to create a .txt file with the metadata used by the pyTivo.
  • I'm conflicted about using pyTivoParsley2 to embed the metadata in the mp4; it seems that the description gets truncated when read by the TiVo and by pyTivo; and not all of the metadata is stored.  I would prefer everything to be contained within the mp4, but I want complete data more.

4. iTunes Metadata

I've found that mp3tag works pretty well at setting the iTunes metadata (including cover/poster art) without having to add it to your library.

5. Done!

At this point I have a .mp4 and a .txt for each movie.  I like to encode the trailers, too, and put them beside the movie (it helps, psychologically, to get into the mood to watch a movie).
They appear in the PS3 (and, presumably, Xbox 360) and are playable from there, and on the iPhone using a DLNA player (or, presumably, via adding to library and syncing it over).

6. Not Done?

The missing pieces that I haven't resolved yet are:
  • Thumbnails (via DLNA)- some images have them, some don't, and I've yet to see a video with a thumbnail, even though I've added a cover image to the file.
  • MiniDLNA currently doesn't serve videos to the TiVo- according to this forum post, it's been fixed, but there's not yet a new TomatoUSB build that incorporates this fix.
  • Even though the chapters and subtitles are stored in the file, only VLC will display them.  Oddly, Media Player Classic displays the chapter names as subtitles; maybe reordering the subtitle/chapter streams will fix it?

1 comment:

Sunset Church of Christ said...

I'm interested in your HandBrake preset list for the TiVo but the link no longer works. Do you still have it or maybe an upgraded preset?