Unix HandbrakeCLI batch script for Apple TV

Handbrake is great for converting movie files to most useful formats, but not so helpful for batch processing. Fortunately it has a CLI version so I created this script to convert all movie files in as directory to an Apple TV friendly format.

To use cd into the directory with the files to convert and then call the script and watch it do it's stuff.

#!/bin/bash

for file in *
do
  filename=`expr "$file" : '([^.]*)'`
  echo "In : $file"
  echo "Out: $filename.m4v"
  HandBrakeCLI -i "$file" -o "$filename.m4v" -e x264 -S 130 -2 -T -a 1 -E faac -B 160 -R 48 -6 dpl2 -f mp4 -X 960 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all
done

Tags: unix