A simple shell script controller for Handbrake's CLI

Nov 27, '06 07:30:03AM

Contributed by: blafusel

I use MacTheRipper or 0sex to rip copies of my DVDs to the hard drive. From there, I then use HandBrake to create a queue of two conversions: one to compress the DVD into a 700MB file, and another one to compress it into an iPod-compatible format.

Usually this has to be done by hand, as Handbrake (the GUI) is not scriptable. However they did provide a CLI version (HBTest) that one can execute in a shell. So I created this script (doconv) that takes the following command line attributes:

doconv /path/to/VIDEO_TS/folder output_filename [full|ipod|all]
For example:
doconv /Users/username/Desktop/rips/MY_MOVIE/VIDEO_TS my_movie all
This makes it easy to batch the conversion of two movies at once, without utilizing the GUI. Read on for more detail on what the script does.

The above command will generate two files in /Users -> username -> Desktop -- note that you'll need to edit the script to replace USERNAME with your actual short username:

  1. my_movie_ipod.mp4 (the iPod-compatible version of the DVD), with the following attributes:
  2. my_movie.mp4 (the big version of the DVD, ~700mb), with the following attributes:
All of these attributes can be looked up by executing HBTest --help. Currently the script (HBTest, that is) assumes a couple of things: always take the first chapter of the DVD to compress, always take the first audio channel, no subtitles, etc. This script screams for a GUI, but my Xcode experience is limited.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2006111622030031