Our World. Our Minutae.

Friday, October 27, 2006

Handbrake: MPEG4 or H.264?

Handbrake, one of the great Mac apps of all time - clean, clutter-free and delivers exactly what it says it will do - it allows you to backup your personal DVD collection or any files from your DVD camcorder that you wish to convert to MPEG-4 or H.264 MPEG-4 - both formats then allow you to drag (or import) into iMovie, Final Cut Express (FCE) or Final Cut Pro (FCP). Another reason to convert and play back your movies as a QT file, you have much better audio & video controls in QT Pro than you do with Apple's DVD player - you can easily adjust contrast, color, brightness and pitch control (though Apple's DVD player does offer much better playback reverse & fast forward).

Handbrake offers many choices but I did not test a wide range of options, I just wanted to test out whether MPEG-4 or MPEG-4 H.264 was the better choice. Since I have Quicktime Pro, my guess is you will need that or FCE/FCP to have the H.264 option (which will automtically appear in the pop up menu in Handbrake if you do).


The bottom line is that you should ALWAYS turn on DE-INTERLACE and ALWAYS choose 2-PASS ENCODING for optimal quality (the file size with one pass is maybe 8% smaller but the quality difference is noticeable so there's no real advantage).

Based on my small tests and my final criteria based on my eyeballing it, MPEG-4 H.264 is about 5-10% better quality - it does encode way slower on all Macs (this was not tested on an Intel Mac). H.264 encoding takes about 75-100% more time when all else is equal so the trade off is your call. There's really nothing wrong with the "regular" flavor of MPEG-4 files - they are fine but to me, they just seem a tad soft. H.264 files are just a tad sharper but it's not exactly like SD compared to HD, it's just slightly better. The file sizes are very close - less than 1% difference so that shouldn't affect your choice.

What also interesting is with QT Pro, you also get AV settings (brightness, contrast, color & tint) to adjust your video quality and with H.264 files, I was able to achieve both a better and "warmer" looking picture by bumping up brightness, contrast level color settings slightly ... that I could not get plain old MPEG-4 to match. Admittedly, the settings in QT Pro are pretty sparse, it's a sliding bar with no numeric value but still interesting.

I also tried adjusting the average bit rate of plain MPEG-4 to an average bit rate of 2,000 - still not as good as H.264 at 1,200 (all other settings unchanged).

So, basically I recommend settings at: H.264, 2-pass, de-interlace and at least an average bit rate at 1,200.

If you more details, keep reading:

My tests are based on the recent film, NATIONAL TREASURE. I selected section 10 as it features a wide range of settings and shots - from exteriors to interiors and tight close up shots of text.

My two main settings were:

H.264, 2-pass, de-interlace and  average bit rate at 1,200.
MPEG-4, 2-pass, de-interlace and  average bit rate at 1,200.

I will just refer to H264 and MPEG4 from here on out to save a little time.

Photos are posted on FLIKR (linked) if you wish to examine them in greater detail at larger sizes. I used GRAB to grab the screenshots from the Handbrake files and I used SNAP PRO X to grab the DVD screenshots.

Front View of the Ben Franklin Museum ...
H264 is just a tad better - column on far right seems to more accurately capture shades of shadows ...

Front View of the Ben Franklin Museum ...
H264 is just a tad better - hard to tell from small view but chiseled words just seem to have a touch more depth in H264.

Front View of the Ben Franklin Museum ...
DVD Screenshot grab for comparison sake - though of course, you could rightfully argue that it's a compressed JPEG so it's not 100% accurate but you can get an idea that the MPEG-4's are not too far from the "base" DVD.

Silence Dogood Signature ...
As a medium shot, it's pretty hard to tell the difference.

Noddles ...
They add a "glow" efffect to the N in Noodles ... if you look at the larger version, the H.264 letters are just a squosh thinner while the MPEG-4 are a little wider and softer ...

You can also compare to the screenshot of the DVD.

Noddles Option A ...
I thought perhaps if I increased the bit rate to 2,000 as I've heard some people use this setting. It does create a much larger file (about 150 MB versus the @94 MB of the other two files and it took about as long as H.264 to convert - result, not much improvement if any at all and it still does not compare to the H.264 version). (the middle version is the MPEG-4, 2-pass, de-interlaced, 2,000 average bit rate).

Noddles Option B ...
I thought perhaps if I manually adjusted the playback quality using QT Pro's rudimentary settings - while it's hard to tell with fake parchment (presumably), you might be able to gleam the picture quality is just a tad warmer with H.264. With MPEG-4, there was no combination of color & contrast & brightness that seemed as warm as H.264 before getting over-saturated and "shadowy," (aka: dark).

Newspaper ...
If you look closely at the classified text ads to the way right, H.264 is just a tad darker and sharper.

$100 ...
H.264 is at the bottom - again, the text is just a tad sharper, the "cloud" effect seems to show off a slightly greater range of shadows and seems less flat. On the larger photo, you can also see the cuticles are just sharper in H.264.

Diane Kruger Adjusted
This is an adjusted playback - again, with H.264, the adjustments just seem a little warmer and "better," while an attempt to match the skin tone produced a darker version in MPEG-4 ... but ultimately, you could argue day and night - as you can see,  the difference is amybe 5-10% depending on the shot ...

Clothing Store
Again, hard to really say ...

So, if you choose MPEG-4 with 1,200 average bit rate, 2-pass encoding and de-interlace, it's a pretty nice picture - a a tad/skosh softer than the DVD but still pretty nice. A typical movie is around 950 MB so you can pack plenty onto any HDD nowadays.

If you want a few ticks sharper and you don't mind the much longer encode times (the file is less than 1% smaller in size) and you have the H.264 encoder, you get a miniscually better picture and your QT Pro playback options seem to offer a warmer range of adjustments. The only choice is a time commitment factor - ultimately, your encode time depends on how much RAM you have and what else you have running so your mileage will vary.

What's not mentioned is that Handbrake will convert PAL to a (NTSC) MP4 file so if you have discs you bought overseas and don't want to fiddle with the idiotic regional playback restrictions, convert them to QT files - with most films less than 1 GB, you can fit 4 on a DVD-R or you can just leave them on a HDD ... Once iTV is released, we can have our own international TV jukebox ... Enjoy!


Anonymous Anonymous said...

I thought Handbrake would be my answer to getting DVD footage into FCE. So I took a number of different non-commercial DVDs that we produce in-house with iMovie or FCE and iDVD and used Handbrake 0.7.1 to make MPEG-4/H.264 files. I used my own settings at first and then yours, and when trying to import into FCE 3.0 on a dual GHz G4 running 10.4.8, I get an error message. When I convert them to .dv format using QT Pro they import just fine. Do you know what I'm doing wrong?

FCE error

File Error: 1 file(s) recognized, 0 access denied, 1 unknown.

3:34 PM

Blogger Metro said...

My other settings are:

Framerate: Same as Source
Audio: English, 44100, 128 (default)

Along the way, I've loaded a bunch of other encoders so I'm not sure if they're part of their process like FFMEG ... I haven't had any problems - are you losing any resolution in re-outputting from QT Pro - make sure to look in the ADVANCED settings and make sure everything is at the best quality ... have you tried re-installing QT? (it will auto sense the Pro part) - maybe somewhere along the line, there's a disconnect for Handbrake?

5:24 PM

Anonymous Anonymous said...

Actually, you've kind of missed the point of H.264 a bit - its not that its particularly better for any given bit rate, its that it can achieve the same results at a dramatically lower bitrate than can vanilla MPEG-4. What you should be comparing is your 1200 bps MPEG-4 to a ~450 bps h.264 of the same size, and you'll see that the quality is comparable, but the file size is obviously smaller. The tradeoff for this is, as you've mentioned, far greater encoding times.

H.264 is a solution for moving hi-quality over a given bandwidth target, and not for absolute quality.

6:34 PM

Anonymous Anonymous said...

So what is the best codec for absolute top quality? I just bought a $120 500GB drive so i can afford to have 2GB movie files or even 3GB files if the quality is much better. I am not trying to stream them just watch them locally.

7:06 PM

Blogger Metro said...

That's an intersting thought. I will try and bump down the bitrate of H.264 and see what I get. I guess it didn't really occur to me as a 90 minute H.264 movie is about 1 GB so the file size was perfectly acceptable to me. I just noticed that Mpeg-4 was nearlt twice as fast so I thought I test out the same.

BTW, if you're just interested in converting it to a file on your computer and you don't really need editing features - check out MAC THE RIPPER. It will convert nearly every retail DVD out there to an unencypted VOB file. You will need VLC to view them (there is a hack somewhere on how to hack your FRONT ROW to "see" VOB files but until iTV comes out, for me it's not a big deal. There's no change in file size - a typical movie on a DVD is 2-3 GB and your final VOB files are the same size.

I'm no expert but I think MAC THE RIPPER just strips out the DRM as it only takes 3-5 minutes to complete the process and HANDBRAKE is no faster at converting a VOB file in a folder on your desktop versus from a DVD disc .

If I have time in the next day or so, I'll update it to try out a lower bitrate at H.264.

11:22 PM

Anonymous Anonymous said...

It pains me to post this. I have done EXTENSIVE tests with handbrake and looked over them with a very critical eye and H.264 and MPEG-4 don't even begin to come close to the quality in the .AVI codec. My sample movie was Harry Potter 3. The footage I used to compare in all my tests was during the Quidditch(sp?) match where the dementors come after Harry. There is a shot, early in the scene, where somebody in yellow robes is chasing the snitch. He gets struck by lightening and reels back. Right before he reels back you get a shot where you can see his eyes through his googles. It is a very demanding image, as much of it is shadow detail. There was absolutely no comparison. AVI trumped them all. And I even tried cranking up the kbps to ridiculous levels. It was a horrifying discovery. I can't remember if I used the de-interlace, though, so I am re-running the tests as I type this. I will only re-post if, by some miracle, this makes a difference.

8:22 PM

Anonymous Anonymous said...

Okay, I've rerun the tests. De-interlace certainly helps the H.264 detail. It is no longer a hands down win for AVI. However, the H.264 was too dark and the color was not as good as the AVI. So, for now, I see no choice but to stick with AVI.

8:59 PM

Anonymous Anonymous said...

AVI is not a codec, but a container, much like .mov or mp4. H.264 is a codec that is in an MP4 wrapper. Which codec are you using? What is the bit rate?

11:48 AM

Blogger Metro said...

Yea, you are right in that the final is a little dark but if you have QT Pro, you can adjust settings on playback or if I'm editing the file, I do it in omovie or FCE.

BTW, I did test out the bitrate settings by lowering it to 600 (the encode time seemed about the same - I did have to jump on to send out some emails but it wasn't a vast amount of difference) but the file size was about halved - and YET, the video quality looked virtually the same (all other settings unchanged) so now I'm trying to determine when Handbrake reads ENCODER: x264 MAIN PROFILE if it's reading my EXPORT settings in QT Pro.

I'll update if I have anything to add.

2:17 PM

Anonymous Anonymous said...

What I would like to see are screenshots at about 200 to 250 %. When you compare DVD to mpeg4 on 100%, you won't see big differences. Most of the time you look at the movies at a big screen (television, 20" computer screen...) and differences tend to get bigger on more noticeable then.

12:47 AM

Anonymous Anonymous said...

why do the de-interlace option? My intention is to play back ona tv from the ipod..

5:33 AM

Anonymous Codecs said...

I certainly like H.264 codec. its one of the best video codec, as it improves the quality as well as shrink the file size with no compromise of video quality


10:14 PM

Anonymous Anonymous said...

I'm having a dilemma with Handbrake, when i adjust the output resolution to match the source resolution the image becomes distorted.... but when i keep aspect ratio the source and output are different?! Why is this, am i just fussing about something stupid??

10:24 AM


Post a Comment

Links to this post:

Create a Link

<< Home