Convert DVDs for iPhone or iPod Touch with HandBrakeCLI
I’m close to my goal of being able to manage my iPod Touch completely without iTunes on Ubuntu. HandBrakeCLI (HandBrake’s command line interface) for Linux encodes excellent quality video, and although it runs in the terminal is simple to use.
Previously I was successful in converting DVDs for playback on my iPod using the HandBrakeGTK GUI, which doesn’t install in Ubuntu 8.04, has broken presets, and has now been abandoned.
I haven’t found a Ubuntu package for HandBrakeCLI, but this isn’t a problem as the program is a single executable file available from HandBrake’s downloads page. You can download and extract it yourself, or follow these instructions in the terminal:
Download the latest version of HandBrakeCLI for Linux. This command will download and extract version 0.9.2 (the latest as I write this):
wget -O - http://handbrake.fr/rotation.php?file=HandBrake-0.9.2_i386.tar.gz | tar xz -C ~
Mark the file as executable:
chmod +x ~/HandBrakeCLI
Move the HandBrakeCLI executable to
/usr/bin
to install it (will ask for your password):sudo mv ~/HandBrakeCLI /usr/bin
Now you should be able to run HandBrakeCLI system-wide.
Before you can convert a DVD, first you need to be able to play it. If the DVD is encrypted and you haven’t set up playback of encrypted DVDs in Ubuntu, see my post on this topic before proceeding.
HandBrakeCLI’s presets mean it’s pretty simple to create a video that will play on the iPod Touch/iPhone. Here’s the most basic command:
HandBrakeCLI -i /media/cdrom -o mymovie.mp4 --preset="iPhone / iPod Touch"
And here’s an explanation of what’s going on:
-i /media/cdrom
Selects the input source, in most cases this will be your disk drive.-o mymovie.mp4
The output file.--preset="iPhone / iPod Touch"
The preset to use, see this wiki page for more presets.
This is my preferred command at the moment:
HandBrakeCLI -i /media/cdrom -o mymovie.mp4 --preset="iPhone / iPod Touch" --longest -b 256
Here I have added a more few options: longest
to make sure the longest segment
of video is the one I am encoding, ([update] markers are
included in the preset), and markers
to make it so I can browse
chapters on my iPod (doesn’t seem to work)b 256
to override the bit-rate to a much lower
value. These settings result in reasonable quality and shrink a two and three
quarter hour movie to under half a gigabyte.
Once you let HandBrake go, it should work until you see the Rip done!
message.
This will take some time depending on your CPU (multi-cores are used) and DVD
drive speed.
The HandBrake wiki has a good page with more information about the CLI:
http://trac.handbrake.fr/wiki/CLIGuide
If you haven’t got your iPhone/iPod Touch syncing in Linux, I’ve got a post for this. Want to encode non-DVD video for your iPhone? I’ve got a guide for this as well.
Archived Comments
Anonymous
From what I’ve seen, you need to use the .M4V file extension for the chapters to work correctly. Just change the extension from .MP4 to .M4V and it should work.
Tom
Anonymous:
Thanks for pointing that out, I’ll remove the redundant markers option from my
command.
Anonymous:
I’ve tried that already, I suspect now that it’s a problem with the video’s
tags.
Anonymous
You don’t need to include the markers option, it’s included in the preset.