Batch Encoding H.264 Video with HandBrake
(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.)
As I mentioned in the preceding section, HandBrake also comes in a command-line edition. As with the graphical edition, you should download a recent snapshot from http://handbrake.fr/downloads2.php.
Like ffmpeg2theora (see Batch Encoding Ogg Video with ffmpeg2theora), the command-line
edition of HandBrake offers a dizzying array of options. (Type HandBrakeCLI --help
in a Terminal window or at a
command prompt to read about them.) I’ll focus on just a few:
--preset "
, whereX
""
is the name of a HandBrake preset (it’s important to put the name in quotes). The preset you want for H.264 web video is called “iPhone & iPod Touch”.X
"--width
, whereW
is the width of your encoded video. HandBrake will automatically adjust the height to maintain the original video’s proportions.W
--vb
, whereQ
is the average bitrate (measured in kilobits per second).Q
--two-pass
, which enables two-pass encoding.--turbo
, which enables a turbo first pass during two-pass encoding.--input
, whereF
is the filename of your source video.F
--output
, whereE
is the destination filename for your encoded video.E
Here is an example of calling HandBrake on the ...
Get HTML5: Up and Running now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.