I’ve had an Apple TV for a number of years, along with an iPod Touch and now (finally!) and iPhone. Before I had any of those things I made a conscious decision to transfer all my CD’s to iTunes and change the way I manage and access my music. This was clearly a success, as I can’t remember the last time I got one of my CD’s out of its case, (come to think of it, I can’t even remember where my CDs are!).

This setup was ideal. The music was wherever I wanted it to be: Streamed through the Apple TV, played off a PC or laptop, or copied to my iPhone. This got me thinking, “why can’t I do the same with my DVDs?”. With the cost of storage being so low I bought myself a 2Tb Lacie drive with that very same thought in mind.

The first problem I ran into is that encoding movie or TV shows is very different to ripping a CD. It’s by no means streamlined or built into the iTunes interface. Hopefully one day this will change (in my crazy utopian vision of the future), but for now we’re stuck with it. I’ve spent quite some time finding the best approach, so I thought I’d share the final solution here.

My aim was to approach the encoding of video for iTunes with the same approach I took with my music: I wanted the quality to be such that I wasn’t aware I was listening to compressed audio (hence my decision to use AAC at 192 or 256kbps). The challenge was to encode the video such that I wouldn’t be distracted by the difference in quality from the original DVD. The aim was to create a library of video (movies and TV shows).

My other aim was to only encode the video once: to produce one file that would play back on the Apple TV, iTunes and iPhone. In theory this aim should be easy to be achieve, but with my background in video production I was unwilling to compromise on quality: the videos had to be full frame, full framerate. Not re-sized in any way. This proved to be a bit of a challenge for the iPod and iPhone, but it is possible.

The final aim was to reach some realistic tradeoff between quality and filesize. This was not only to save my HDD from exploding, but also to keep within the specifications for the iPhone/iPod which couldn’t handle high bitrate video.

I’m both a PC and a Mac user, and for convenience I manage my iTunes library on my PC. I’m using the freely available Handbrake software to encode the videos, which is available for both Mac and PC – so don’t be put off by the screenshots. This solution is multi platform. This article was written for Handbrake v0.9.3 (PC).

Please note that both the PC and Mac versions of Handbrake do not allow encoding directly from encrypted/commercial DVDs. I’m not going to discuss how you get around this limitation – but there are plenty of solutions. Google will help you find them ;o)

So (finally) here we go:

  1. Firstly, download and install Handbrake from the web. When you run the application you’ll see a number of built in preset, including ones for our target devices. The problem is that these built in presets only target individual devices (i.e. videos encoded with the Apple TV preset will NOT work on your iPhone). The built in presets for the iPod and iPhone significantly resize the video for those devices, which in turn look bad when played on the Apple TV.
  2. Select the preset “iPhone and iPod Touch“. This is a good starting point for our custom preset, as we know this preset will work with the lowest common denominator in our system: The iPod.
  3. Under the “Picture Settings” tab change the “Anamorphic” setting to “Strict“. This will force the videos to be encoded anamorphically which will help increase the quality at a lower bitrate. The strict mode also forces the video to be encoded at the exact same frame size as the source. For Europe/PAL videos this will be 720×576 pixels, and USA/NTSC DVDs it will be 640×480 pixels. You may have spotted that those pixel ratios are actually 4:3, not 16:9. Anamorphic widescreen works by squeezing the 16:9 image into a 4:3 frame, which is then stretched during playback. This is how DVD players display 16:9 content, and we want to use the same method here. Our encoded videos will technically be 4:3, but with instructions to the players to stretch the image during playback. It’s also worth noting that 720×576 is beyond the specifications for the iPhone and iPod (according to Apple), but the videos playback fine without problems. Trust me :o)
  4. Under the “Video” tab enter “1900” as the “Avg Birtate (kbps)“. This is the parameter I’ve spent the most time experimenting with: 1900kbps will give you a decent trade off between quality and filesize. If you want to increase this be my guest, but be aware that the iPhone will not accept videos over 2500kbps.
  5. Under “Audio and Subtitles” you may wish to add a second audio track with the original AC3 (5.1 surround sound) track from the DVD. Currently only the Apple TV supports playback of this 2nd audio track, but it makes such a difference to watching movies that you may wish to include it. It will increase the file size a little. (Note that under my PC version of Handbrake you can’t add this 2nd track unless you open a DVD – with AC3 – to start with. Just open a DVD and go back to step 2)
  6. Finally (and after much tweaking) there’s a few extra parameters under the “Advanced” tab you may wish to change:
    1. Reference Frames = 3
    2. Sub-pixel Motion Estimation = 7
    3. Deblocking = -2 | -2
      (The deblocking has the most impact. The encoding process blends the edges of the individual DCT blocks to make encoding artifacts less noticeable – however I feel it blurs the video too much. To make the final video closer to the original DVD I’ve found that this setting does the trick – particularly with widescreen video.)
  7. … and that’s your lot. Save the preset and give it a friendly name. You’re all set to encode high quality videos that will playback on all your Apple devices.

handbrake-screenshot1

Because of the nature of these settings, this solution will work for both NTSC and PAL DVDs. I haven’t tried the preset with 4:3 TV shows yet – nor have I worried too much about interlacing. I find the best strategy is to do a quick test encode of a video you’re unsure about. If it needs it, apply the “deinterlace” filter or change the “anamorphic” setting to “none” if necessary. I’ve not needed to do either of these things yet.

For the encoding of TV shows I find it best to copy the DVDs to my HDD before encoding, and then set up a batch list in Handbrake so it can crunch away overnight.

The step after encoding is of course to import them into iTunes. I’ve been using iTunes to edit all the meta data (and IMDB for the source of that data). It’s a bit tedious, but well worth it. If you’re using a Mac you may want to look at getting MetaX for this step. I haven’t used it, but it looks ideal and has plenty of good reviews. (There is a PC version, but give it a wide berth for now!)

You may be surprised at the bitrate, given that it’s less than 2Mbps. To be honest, I found this to be more than adequate for my needs. You also need to consider the source material. Most commercial DVDs encode the video at between 2-4 Mbps MPEG-2. The codec we’re using (H.264) is more complex than MPEG-2, and more efficient at compressing video to lower bitrates. With that in mind, it’s clear that anything over 2.5Mbps is unlikely to yield better results. After all, the only purpose for these videos is playback – not editing or re-encoding.

So there you have it. I’m certainly happy with this setup. I’ve encoded about 30 of my movies using it, and I’m working my way through 4 seasons of Battlestar Galactica using both the Apple TV and iPhone for viewing. The files can be a little large of the iPhone – but for the convenience of not having to re-encode the video it’s fine. Also, if you own an AV cable for your iPhone you’ll be amazed at the quality of these videos on playback!

If you have any suggestions feel free to add them to the comments. Also, please let me know if there’s any specifics for the Mac version that I missed.

Enjoy!


6 Comments

Rich B · 23 May 2009 at 11:09 pm

That’s super useful Oli, it’ll save a lot of people a lot of time. Top man for posting.

Phil · 6 July 2009 at 5:18 pm

Now then – good information! I’ve set up Handbrake (v0.92 I believe) with the settings you’ve specified and when I rip a DVD the resulting file (for a 2 hour movie) is about 1.7GB. Is this about right?

Also, my poor old G5 takes about 12 hours to encode a 2 hour DVD! Can’t see myself converting my 150 DVDs any time soon – at least not until I get a more powerful machine!

Oli · 7 July 2009 at 8:41 am

Yeah, that’s about right. You can always drop the bitrate or framesize if you want smaller files – but I think this is the best solution for future proofing your encoding ;o)

As for the G5 – yes, it’s painfully slow. I gave up using my old iMac and switched to my quad-core PC. I find a 90 minutes movie takes about 45-60 minutes to encode … which is a bit faster!

Phil · 7 July 2009 at 4:07 pm

So your setup is a hefty PC for all the “number crunching” with big external storage, and then the Apple TV for getting it all onto your HDTV? I’m still slightly perturbed that you got rid of your Mac, but I guess the old G5 is getting a bit geriatric for demanding things like video encoding…

Just a thought – can you recommend some DIY specs for a PC hefty enough to cope with this kind of thing that really is genuinely cheap, or does the requisite power automatically mean “expensive”? I’m out of touch with PC components – are quad cores still awesomely pricey?

Oli · 8 July 2009 at 8:47 am

Off the top of my head, any Core2Duo system speeds up the encoding significantly. The Intel Mac Mini is an example: I’d say encode times increase at least 4-5x going from the G5 iMac to an Intel Mac Mini.

Other than that, the more cores you can throw at it the better. Quad cores aren’t that expensive these days so long as you don’t go for the top speed ones. My 2.4GHz quad is very snappy!

Finally – just to piss you off – I’m currently setting up a QMaster encoding cluster at work which will offer me around 80 processor cores for encoding 🙂 – With that setup I imagine a typical movie will encode the day before you knew you wanted to encode it. Magic!

Phil · 16 June 2010 at 1:56 pm

Sorry to restart this whole conversation again (a year later…) but I notice that now we’re on Handbrake 0.9.4 a lot of the complicated looking presets have disappeared.

Essentially, there are now 6 (although they’ve included some “legacy” ones) – four for Apple devices, 1 normal and 1 high-profile.

The four Apple ones are; Universal, iPod, iPhone/iPod Touch and AppleTV. Clearly the three specific ones are designed to optimise for their target device – but how do you feel about the “Apple Universal” preset? It’s supposed to work on all platforms – desktop, iPod, iPhone, AppleTV. Any good? How does it differ from the instructions you gave above? Any advantages/disadvantages?

Leave a Reply

Avatar placeholder

Your email address will not be published.