Wednesday, November 22, 2006

More on Ripping DVDs

In Ripping DVDs with HandBrake (Part 2) I said MacTheRipper was next on my list of experiments with ripping DVDs. MacTheRipper is software that imports files from a DVD into a folder on a Mac's hard drive.

A DVD is nothing more than a bunch of computer files and folders. If it weren't for copy protection, you could just copy them to your hard drive and play them from there, using Apple's DVD Player application. In fact, I'm told that simple method actually works with some DVDs.

MacTheRipper, on the other hand, copies all DVDs, without copying the copy protection. It also defeats the regional coding which keeps you from playing DVDs from foreign lands.

MODmini's "Saving DVDs as VIDEO_TS Files" page (part of its "How-To: Turn Your Mac mini into a DVD Jukebox" article) advises to use Matinee along with MacTheRipper. Matinee front-ends your folder(s) of ripped DVDs and makes playing any of the movies in Apple's DVD Player a one-click affair. Matinee simply fires up MacTheRipper when you tell it you want to rip a new DVD.

I downloaded both of these items of free software. Once I dealt with some minor perplexities, both worked straightforwardly. So far I've ripped both discs of Lord of the Rings: Fellowship of the Ring Extended Edition and also Meet the Parents Bonus Edition. All the ripped versions seem to play in DVD Player just as if they were on the original disc. You get the whole DVD menu system intact, allowing you to choose language/subtitle options, special features, etc., as well as the main film.

The next thing to try would seem to be burning the ripped files to a do-it-yourself DVD-R and seeing if that disc works in various standalone and computer DVD players. But I ran into a snag there: the files won't all fit on a 4.7GB single-layer DVD-R! Since the original DVDs are dual-layer, it would seem that I need to use dual-layer DVD-Rs. I don't at this point even know if they exist though, or whether my MacBook Pro's internal SuperDrive could burn them.

Until I find my way down that path, more now on using HandBrake to rip and compress a DVD all in one fell swoop.

I am continuing to experiment with Handbrake's various options for choosing:

  • codecs
  • encoders within codecs
  • target file sizes, average bitrates, or "constant quality" percentages

The object of the game is to make HandBrake's output file as small as possible, consistent with "good enough" picture quality (PQ). HandBrake decodes the video on a DVD and re-encodes it in a different codec. The codec used on a DVD is always a form of MPEG-2. That used by HandBrake's output files is a form of the newer, better MPEG-4.

The main idea here is that MPEG-2 compression is inefficient and results in big files with high bitrates. MPEG-4 compression can produce nearly as good PQ with smaller output files and lower bitrates. The AVC/H.264 codec (which is one of HandBrake's two choices, in addition to MPEG-4) is actually a high-class version of MPEG-4; it supposedly does even better.

Within either of these codecs in HandBrake you can choose a target file size or an average bitrate, resulting in a constant bit rate (CBR) in the output encoding. If you want a variable bit rate (VBR) so that more bits will be allocated to scenes that are harder to encode and fewer bits will be wasted on easy-to-encode scenes, choose a "constant quality" percentage — instead of a target size or bitrate, that is.

I've been trying 50% "constant quality" (CQ50) AVC encoding with pretty good results: tolerable picture quality, fairly compact (but widely variable, depending on the movie) file sizes.

I've also been trying using a bitrate of 1000 kbps with 1-pass MPEG-4 encoding. Comparing the results in QuickTime for Lord of the Rings: Fellowship of the Ring Extended Edition Part 2, I believe a CBR MPEG-4 encoding at about 990MB for the output file looks better (!) than a VBR AVC encoding that produces a 1.15GB file. At least in some scenes — those in which there is a somewhat uniform medium-to-dark gray backdrop, mainly — there is less of a tendency for solid blocks of a single color (visible "macroblocks") to show up and flicker on and off, thereby harming the naturalness of the scene.

There are many variables here. Using a bitrate of 1000 kbps with 1-pass MPEG-4 encoding, I have tried both the XviD encoder and the FFmpeg encoder in HandBrake. The results are very, very close both in PQ and file size ... but I think the XviD encoder does just a smidgen better with at least one critical scene.

One of the things that has gotten in my way in making these evaluations is that iTunes' Full Screen mode for viewing movies seems to exacerbate the inherent macroblocking in the recordings. A movie viewed in Fit to Screen mode may look pretty good in iTunes, but switch to Full Screen mode and the overall brightness scale is boosted in a way that brings out the macroblocks. This anomaly does not happen in the equivalent modes in QuickTime Player.

A good way to evaluate the various HandBrake encoding options is to view their respective outputs side-by-side in QuickTime Player Fit-to-Screen windows. When you come to a problematic scene in one window, pause it and cue up the same scene in the other window(s). Then compare.

More later.


Anonymous said...

I just found this blog, not sure why I didn't see it earlier. Is this all still in the contemplation phase? I've been using a Mac Mini as an HTPC under the TV since it was introduced - and a broken-screen powerbook for a year before that. I've worked out a lot of issues and created some workarounds for difficult issues. Theere are some issues that just can't be overcome - eg getting encrypted digital cable onto the mini in an easy way. As to ripping DVDs though, I've gotten it down pretty well. My advice: Handbrake in MPEG-4 format, at a bitrate of 1200-1500, deinterlaced and with a maximum horizontal resolution of 624 pixels. This results in file sizes of about 1GB per 90 minute movie, at near-DVD quality, and it allows for playback on an iPod Video... which means maximum portability when you have the iPod AV Cable.

Handbrake can't make iPod-playable videos in AVC at near-DVD quality - you have to go down to 320x240, which is crap. So while you can save 25-20% on file sizes by going with AVC, I don't think it's worth it if you have or contemplate having a video-capable iPod. On the other hand, if you don't use video with an iPod, you might as well go with AVC at full-resolution.

eric said...

Anonymous, thanks for your comments. Yes, it's still in the contemplation phase. I'm going to wait until the Apple iTV product comes out before finalizing plans. I could get one of those, or a mini, or both.

I also need for Apple to come out with a revised mini with HDMI output. DVI won't do 'cuz it doesn't carry audio. The iTV product will have HDMI. I bought a Sony LCD HDTV that has lots of HDMI inputs but no other digital audio inputs. My Yamaha digital sound projector meanwhile accepts no HDMI inputs but has an optical digital audio input from the TV. But its relatively few digital audio input ports (3) are already maxed out. The only way I can get digital sound from a Mac mini to the DSP is via HDMI to the TV and then via digital optical cable to the DSP.

I too find using HandBrake in MPEG4 format an excellent solution. I'll keep your recommended settings in mind under the assumption that I will one day replace my iPod 3G with an iPod Video and an AV Cable.