How to batch process videos using HandBrake and Hazel | Dafacto

The personal website of Matt Henderson.

How to batch process videos using HandBrake and Hazel

28 November 2011

I’ve tried just about every video encoding product for MacOS X, and always keep returning to the venerable HandBrake.

Why haven’t I just stuck with HandBrake in the first place? One reason — its UI for batch converting videos sucks. Unlike all other products, you can’t just drag a bunch of videos into HandBrake. No, you have to chose them one at a time, and manually add them to the HandBrake queue.

Why haven’t I stuck with one of the other products? Because none of them have presets that are as good as HandBrake’s, and I couldn’t be bothered to learn the FFMPEG syntax. For example, all the presets in something like RoadMovie will change the resolution of the encoded video. HandBrake’s “Normal” preset will preserve the video’s original dimensions.

This weekend, with the help of Super-Makalu Justin Driscoll (@jdriscoll), I finally created a batch processing system, based on HandBrake. This article documents the setup.

What you need

  • (HandBrakeCLI). This is a version of HandBrake that can be run from the command line. Don't expect the "doc" folder that comes with this utility to actually tell you how to install it. That'd be asking too much. Fire up Terminal, navigate to wherever HandBrakeCLI is, and move it to your /usr/bin directory with this command (you'll be asked for your admin password).
  sudo mv ./HandBrakeCLI /usr/bin
  • Hazel. Hazel is a System Preference utility for the MacOS X, that allows you to schedule regular actions to be made on the contents of folders. Download and install.
  • This bash shell script, which you can copy and paste later from Pastie.

Basic idea

I have the following folder structure:


We’re going to tell Hazel to watch the “input-ipod” folder, and whenever it finds a new video file, to process that file with HandBrakeCLI, and then move the original into the “processed” folder.


  • Once Hazel is installed, add the "input-ipod" folder to its watch list.
  • On that folder, create the following rule with two steps: (1) the first runs an embedded shell script (passing each video file to HandBrakeCLI for processing) and, (2) when done, move the original video to the "processed" folder, which you can later delete or whatever.

One setup, all you have to do is drop videos into the “input-ipod” folder, wait a few moments, and watch Hazel kick into action. I set this up on our 8-core iMac at home, and watched it blow through 100 videos. Yeah!


The Hazel embedded script will fail if the original video has spaces in the name. So be sure to change “My Home” to “” before dropping into the input folder. I haven’t taken the time to sort that out yet, but will update this blog when I do.


You’ll notice that I’ve named my watch folder “input-ipod”. As you can imagine, I have other input folders named “input-appletv” and “input-normal”, for dropping videos I want processed with HandBrake’s “AppleTV 2” and “Normal” presets. I modify the Hazel embedded script accordingly for those rules. A complete list of HandBrake’s presets can be found here.

Hope this article helps others wanting to do the same. If you do, I’d love for you to drop a “Hello” message in the comments below.

Enjoy this article? — You can find similar content via the category and tag links below.

Questions or comments? — Feel free to email me using the contact form below, or reach out on Twitter.