Tuesday, November 21, 2006

Ripping DVDs with HandBrake (Part 2)

Here's the second installment in my Ripping DVDs series. The first was Ripping DVDs with HandBrake (Part 1). HandBrake is free software your Mac can use to rip DVDs into computer files for later play without the original DVD.

At the MODmini website I found this helpful how-to on HandBrake and like topics, in addition to the three tutorials cited in the earlier post. (The HandBrake stuff is on the "Converting DVDs for QuickTime Playback" page of the four-page article.)

The MODmini turorial talks about doing just what I want to do: turn the Mac mini I intend to purchase into a discless "DVD jukebox." The same site also offers "DVD Kiosk How-To," discussing the ins and outs of using the Mac mini as a simple DVD player, complete with a functional remote control, to play optical discs directly.

I am still fooling around with HandBrake in an effort to figure out just how I want to use it. One option would be to rip each DVD movie into as small a computer file as will yield tolerable picture quality (PQ) on playback. The enemy of picture quality is digital video compression. Too much compression causes picture artifacts: digital "noise," pixellation, macroblocking, etc. But as you reduce the degree of compression to minimize artifacts, the file size explodes.

Going for small file sizes results in PQ compromises. I experimented yesterday with the idea of using a target size that will fit on a writeable CD, and I found the strategy to be somewhat viable but problematic. My idea was that squeezing files down to CD size will allow me to store a lot more movies on my hard drive and will let me optionally archive them to CD.

A recordable CD (a CD-R or CD-RW) holds 650 or 700 megabytes, depending on the CD. When I set HandBrake to use a target size of 700 MB, it actually produced a file a bit larger than that — too large for my purposes. Re-ripping with a 650-MB target size gave me a file comfortably under 700 MB. However, the 700-MB CD-RWs I first tried to use to test burning my HandBrake files seemed to cause unrecoverable problems or have fatal defects in them, so I re-ripped yet again with a 600-MB target size, for a file under 650 MB that would fit onto a 650-MB CD-R.

I had in earlier experiments determined that, for any given target file size, HandBrake's AVC/H.264 video "codec" ("coder-decoder") gives better PQ results that its alternative, the MPEG-4 codec — at the expense of longer ripping times.

I don't really understand that lingo, but I believe the "AVC/H.264" codec implements Part 10 of the MPEG-4 standard for video encoding and compression. The "MPEG-4" codec implements Part 2 of the same standard. Any AVC/H.264 or Part 10 codec is supposedly "capable of providing good video quality at bit rates that are substantially lower (e.g., half or less) than what previous standards [including MPEG-4 Part 2] would need." So Part 10 is better than Part 2 at any give bitrate — though slower. From now on I'll refer to these two codecs in HandBrake as simply MPEG-4 (for Part 2) and AVC (for Part 10).

So my under-650-MB experimental file used AVC, not MPEG-4. The actual AVC "encoder" choice that I selected in HandBrake was "x264 (Main profile)," not "x264 (Base profile)." The ability to select among different encoders within a given codec is not one I fully understand the ramifications of yet. In earlier experiments I have found the Base Profile AVC encoder generates slightly larger files than the Main Profile encoder.

That ripped-DVD-file-copied-to-CD proved to work fine on my MacBook Pro, the fast new Intel-based computer on which I made it. But when I tried it in iTunes on my older, slower iMac, playback stuttered. Yet playback in QuickTime on the same iMac went fine. iTunes likewise stuttered when I copied the AVC file from the CD to its hard drive and played the copy. It also stuttered when, via my AirPort Extreme network, I played the original file that was on the MacBook's hard drive into iTunes on the iMac.

My conclusion: my iMac's 1-GHz PowerPC CPU just isn't fast enough to cope with AVC video in iTunes, though it unaccountably does fine with the same AVC video in QuickTime. The actual source of the AVC video file — the iMac's own hard drive, a CD, the network — doesn't matter.

On the other hand, the iTunes/iMac combintion does just fine with MPEG-4 video rips. Still and all, for now I'm sticking with the higher quality of AVC and expecting to play the results either on a fast Mac or in QuickTime on my slower Mac.

Even though the PQ is better with AVC than MPEG-4, for any given target file size, HandBrake offers you ways of improving it even more. One is to abandon the target file size in favor of a target average bitrate in kilobits per second. The two are joined at the hip. If you input a target size, the bitrate (though grayed in the HandBrake panel) changes accordingly, and vice versa. Both methods use a constant bitrate; they provide two different ways to determine what that bitrate will be. You can set the bitrate you want directly. Or you can set the file size and let HandBrake figure out what bitrate goes with it.

But as the "Converting DVDs for QuickTime Playback" page of the MODmini DVD Jukebox article says, a constant bitrate (CBR) limits the quality of scenes that need higher bitrates. With a variable bitrate (VBR), "the movie takes more space where more things are happening, and less space when not much is going on."

You are telling HandBrake to use VBR when you choose "constant quality" video instead of a target file size or bitrate. When you do that, you get to adjust a slider to set the quality you want. It's graduated in percentages, where 100% gives you the best possible PQ, using the most hard drive space. The default setting is 50%. MODmini says each additional 10% above that roughly doubles the file size.

Right at this minute, I'm experimenting with constant-quality AVC and MPEG-4 rips. My attempts to encode full-length movies at CQ100 (i.e., a constant quality of 100%) have thus far caused mysterious HandBrake failures toward the end of the ripping process, generating huge unopenable files. Possibly the file sizes became too big for Mac OS X to deal with.

When I switched to experimenting with ripping just a single chapter of a DVD, CQ100 worked fine, at least with MPEG-4 video. The result looks pretty good, too ... but so does CQ90 or even CQ80 with AVC video. I'm currently experimenting with CQ80 AVC. Specifically, I'm ripping Lord of the Rings: Fellowship of the Rings, Pt. 1, from the Special Extended DVD Edition of that already-classic film. It's the first 1 hour, 45 minutes, 30 seconds of the movie on the disc.

Well, that didn't work! HandBrake went through its connipitions and combobulations for an hour or two, got to where its progress bar reached 100%, and vanished without a trace, leaving me with another unusable output file, this one of some 5.5 GB. Again, I think these may be file sizes too large for Mac OS to handle. Or maybe HandBrake can't handle them when it tries to finish up — during the delay after the progress bar reaches 100% before HandBrake is done with the rip.

It occurs to me, though: do I really care whether HandBrake can produce files that aren't much smaller than the content of the original DVD? The dual-layer Fellowship DVD contains 6.9 GB of material. That includes several soundtracks, several separate video and audio files for the individual chapters of the movie, multiple menus, multiple subtitles, a lot of control information for the DVD player to figure out how to use the disc, etc. When I rip it in HandBrake, I filter out a lot of that information.

For example, when I choose a subtitle or captioning option — since I'm hard of hearing — the captions get "burned into" the movie. In playing the ripped copy, I can't turn them off. As such, they don't represent "extra" information, as they do on the DVD.

Likewise, all information about chapter stops is lost in the ripped copy of the DVD.

So a rip that exceeds 5 GB while giving me lower picture quality and less playback flexibility isn't all that wonderful. If I want to give up 5 GB of hard drive space, I might as well give up 6.9 GB and have all the picture quality and flexibility of a DVD.

One simple way to do that that sometimes works (see the MODmini "Introduction" page) is to open the DVD in Finder as if it were an ordinary hard drive or folder and drag its VIDEO_TS and AUDIO_TS folders to the Desktop, or to one of your own folders. Copies of the original DVD's folders will be made on your hard drive; it takes several minutes. Then, fire up DVD Player and, per MODmini, "select Open VIDEO_TS Folder in DVD Player's File menu. Navigate to the copied VIDEO_TS folder and your movie will play just as if from the DVD. Easy, free, and no additional software is needed."

Alas, with some DVDs it may be that simple, but "the Finder-copy method may not work on all DVDs, or on all computers. We’ve successfully tested many, many DVDs, but we’ve also seen Finder fail to copy some and DVD Player refuse to play others." With Fellowship, I can copy the necessary folders, but DVD Player won't play them, due to copy protection.

That's where MODmini's "Saving DVDs as VIDEO_TS Files" page comes in. It's method, more general if more complex, relies on Matinee and MacTheRipper software.

"MacTheRipper streamlines the process of saving your DVDs to your hard drive. Not only does it slice and dice exactly which of the DVD’s contents should be saved, but it can also reset region encoding, remove Macrovision copy-protection, and perform a number of other advanced tasks."

Then it's Matinee's turn. "Matinee provides a convenient, TV-suitable interface for selecting the movies on your hard drive, and watching them via DVD Player. It comfortably fills the gap between the Finder and DVD Player, and is easily controlled with a remote."

I've downloaded MacTheRipper (great name!) but haven't played with it yet. That's next on my agenda. Stay tuned!


Jim said...

You didn't read the HandBrake user guide, did you? Read the following page...


Here's the important part:
"So should you use 100% to perfectly preserve the source? Nope. Not at all. In fact, you'll end up with video that's way larger than the DVD, but doesn't look any better.

See, DVDs use lossy compression to squeeze down the raw video the studios use to make them -- sort of like a quality level of 80%. It throws away detail. When HandBrake uncompresses the video prior to conversion, the quality lost when the DVD was made is still gone. When you use 100% quality with x264, you're telling it to losslessly preserve the uncompressed video feed, not to losslessly preserve the DVD. Both have the same picture quality, but the uncompressed feed takes up a lot more space.

To sum up: when converting from a DVD source, there is no reason to go above 80% quality, which is roughly equivalent to how heavily the DVD is compressed. If you do go higher, your output will be larger than your input!"

eric said...


Thanks for pointing that out. I have learned a lot more about HandBrake since I made the original post. Not that I fully understand the complexities of recoding video from the MPEG-2 codec used on DVDs to the MPEG-4/H.264 codec HandBrake, mind you.