• Batching video transcodes with Handbrake (Windows)

    by  • February 22, 2010 • Handbrake, transcode, windows • 2 Comments

    I keep all my media in a central location on a network store but I want to be able to play it on my iphone when I’m away without network connectivity. Most of the content is avi/divx/xvid which the iphone does not play natively.

    Handbrake is a really slick transcoder which converts a wide number of video formats to those compatible with mobile devices. It offers a number of built-in profiles for many mobile devices, including the iphone, and comes as UI or command line interface.

    Here’s a quick and dirty batch script for Windows which processes a given folder (this assumes you installed Handbrake into the default directory):

    1. FOR /F "tokens=*" %%G IN (DIR /B /S *.avi’) DO "C:\Program Files\Handbrake\HandBrakeCLI" -i "%%G" -o "%%G".mp4 —-preset="iPhone & iPod Touch"

    Copy this into a .bat file in the root of the media folder you wish to transcode the media from. This script will iterate through all the .avi files in the folder, calling Handbrake, and creating an .mp4, suitable for playback on the iphone/ipod touch.

    You can customise the batcher to suit, replacing *.avi in the DIR part of the batch file (which provides the input to drive Handbrake) with the type of media file you want to deal with, or replacing the --preset argument with any of those mentioned in the Handbrake wiki (there are profiles for most common devices, including Xbox 360, PSP, PS3, AppleTV etc). Great thing is, I can run the script and leave the PC whirring away overnight

    About

    Web Developer for MRM Meteorite. Awarded a PhD in research into novel techniques to detect misbehaviour in peer-to-peer wireless networks. Experienced C# and ASP.net developer, with an interest in SOA, RIA and moble app development.

    http://www.paulkiddie.com

    2 Responses to Batching video transcodes with Handbrake (Windows)

    1. Mat Landers
      October 3, 2011 at 3:44 am

      Mr. Kiddie,

      Thank you SO MUCH for this batch script! I did have to make a few minor changes to it in order to get it to work. I wanted to let you and your audience know so they can easily use this if they have a similar setup.

      On the DIR part, make sure to replace the single quotation with the single quotation next to your enter key on the keyboard. For some reason it is not the same character and will not be interpreted correctly. The same thing is with the –preset. The first dash seems to be a little longer.

      For 64-bit systems (I am running Windows 7 Ultimate 64-bit) it is important to remember that the default installation is in the Program Files (x86) folder, not simply Program Files.

      Excellent script! I am using it right now.

      Thanks a bunch!

      Mat

    2. Corrected
      November 16, 2011 at 11:37 am

      FOR /F “tokens=*” %%G IN (‘DIR /B /S *.avi’) DO “C:\Program Files\Handbrake\HandBrakeCLI” -i “%%G” -o “%%G”.mp4 –preset=”iPad”

    Leave a Reply

    Your email address will not be published. Required fields are marked *