Batch Encoding H.264 Video with HandBrake
(Just as in the previous section, in this section I’m going to use “H.264 video” as a shorthand for “H.264 baseline profile video and AAC low-complexity profile audio in an MPEG-4 container.” This is the combination of codecs+container that works natively in Safari, in Adobe Flash, on the iPhone, and on Google Android devices.)HandBrake also comes in a command-line edition. As with ffmpeg2theora, the command-line edition of HandBrake offers a dizzying array of options. (Type
HandBrakeCLI --help to read about them.) I’ll focus on just a few:
--preset "X", where “X” is the name of a HandBrake preset. The preset you want for H.264 web video is called “iPhone & iPod Touch”, and it’s important to put the entire name in quotes.--width W, where “W” is the width of your encoded video. HandBrake will automatically adjust the height to maintain the original video’s proportions.--vb Q, where “Q” is the average bitrate (measured in kilobits per second).--two-pass, which enables 2-pass encoding.--turbo, which enables turbo first pass during 2-pass encoding.--input F, where “F” is the filename of your source video.--output E, where “E” is the destination filename for your encoded video.
you@localhost$ HandBrakeCLI --preset "iPhone & iPod Touch"
--width 320
--vb 600
--two-pass
--turbo
--input pr6.dv
--output pr6.mp4
From top to bottom, this command runs HandBrake with the “iPhone
& iPod Touch” preset, resizes the video to 320×240, sets the average
bitrate to 600 kbps, enables two-pass encoding with a turbo first pass,
reads the file pr6.dv, and encodes it as pr6.mp4. Whew!