Skip to content

Instantly share code, notes, and snippets.

@halbtuerke
Created October 22, 2010 06:29
Show Gist options
  • Save halbtuerke/640051 to your computer and use it in GitHub Desktop.
Save halbtuerke/640051 to your computer and use it in GitHub Desktop.
Batch convert videos with HandBrake CLI
#!/bin/sh
# This script converts any kind of video the HandBrake CLI can handle
# into a 1000 kbit MPEG4 video and shrinks it down to a max width of 640 px.
#
# Usage:
# Running the script without any parameters just uses *all* files in the
# current directory and converts them, so make sure you only have video files
# in the directory you're in.
#
# You can specify an input and output directory if you want:
# 'script <INPUT> <OUTPUT>'
#
# The script also assumes you're using Mac OS X and have 'Growl' and 'growlnotify'
# installed, if you don't then just comment out the last line.
if [ ! -n "$1" ]; then
IN='.'
OUT='.'
else
IN=$1
OUT=$2
fi
cd "$IN"
for InputItem in *;do
/Applications/HandBrakeCLI -i "$InputItem" -o "$OUT/${InputItem}.mp4" -b 1000 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -X 640
done
growlnotify "Conversion done" -m 'Have fun with your new files' -s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment