Convert to iPhone with (OS X) Automator and HandBrakeCLI

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
Eddiee
Posts: 1
Joined: Mon Nov 16, 2009 12:42 pm

Convert to iPhone with (OS X) Automator and HandBrakeCLI

Post by Eddiee »

Hi,

Since I'm realy lazy, using the Handbrake App everytime I wanted to convert an episode of The Big Bang Theory for my iPhone was just to munch work :wink: .

This is where the HandBrakeCLI and Automator come in handy.
I created an automator program, which converts any supported video format with the iPhone presets and saves it as originalfilename.mov in the same folder as the original video file. All you need to do is drag and drop the file you want to convert on the automator program.

Since I put this together with the help of the internets, I thought giving something back would only be fair.

1. Create a "Program" in automator.
2. Add a "Run Shell Script" action with this script:

Code: Select all

 for f in "$@"
do
echo "Converting $f for iPhone";
echo "$f.mov";
/opt/local/bin/HandBrakeCLI -i "$f" -o "$f.mov" -e x264 -S 100 -a 1 -E faac -B 128 -R 48 -6 dpl2 -f mp4 -X 480 -m -x level=30:cabac=0:ref=2:mixed-refs:analyse=all:me=umh:no-fast-pskip=1;

done
2.2 Depending on where you installed the HandBrakeCLI, you'll have to modify the path (/opt/local/bin/HandBrakeCLI)
3. In the "Run Shell Script" action, set "Pass input" to "as arguments".
4. Save and close automator.
5. Drag any supported video format on your automator program in finder.
6. Profit!

Please note that -S 100 tells HandBrake to create a new file with the maximum size of 100MB. I use 100MB because I only convert small shows with it. They still look great on the iPhone at 100MB.

/opt/local/bin/HandBrakeCLI -i "$f" -o "$f.mov" -e x264 -S 100 -a 1 -E faac -B 128 -R 48 -6 dpl2 -f mp4 -X 480 -m -x level=30:cabac=0:ref=2:mixed-refs:analyse=all:me=umh:no-fast-pskip=1;
maestrochip
Posts: 1
Joined: Mon Jan 11, 2010 1:22 pm

Re: Convert to iPhone with (OS X) Automator and HandBrakeCLI

Post by maestrochip »

hi there,

your script leads to an infinite loop.
the output of each iteration of the script feeds in as a new source file for subsequent iterations.

x.
Post Reply