Batch Converting Video Files on Ubuntu Linux using HandbrakeCLI

Written by Sam McGeown
Published on 10/3/2011 - Read in about 1 min (162 words)

Disclaimer: this post is more for my own recollection than anything else! When it comes to Linux, I’m an amateur and everything I do from the simplest thing upwards is copy-and-paste from much more informed bloggers and websites!

My home server is running Ubuntu Linux 10.10 – access is via an SSH client only. I run an NFS file server for my home network, which stores my Music and Video for the network, and is running an iTunes server. Most of my DVDs have been ripped to high quality MP4 files for viewing on PC, but they aren’t suitable for my iPhone, so I also frequently compress them for viewing on that device.

The following command lists the files in the Source folder and runs Handbrake via the CLI to convert the files using the iPhone template and spits them out to the Video folder.

for file in `ls /media/Data/NFS/Source/`; do $(HandBrakeCLI -v -i /media/Data/NFS/Source/${file} -o /media/Data/NFS/Video/"${file%.vob}.mp4" --preset="iPhone & iPod Touch"); done
Share this post