• I’ve been working with some AppleScript lately to help with my video conversions, and I’ve come up with something that saves me quite a bit of hassle.

    It uses the free command-line interface of Handbrake called HandbrakeCLI, and is able to convert all videos from specified extensions (ex. avi and mkv) to something that is a bit more widely supported (ex. MP4). All you have to do is point it to a directory and it will start converting all matching videos one-by-one.

    How does it work? This is (kind of) a step-by-step walkthrough of how the code processes files if you’re using it without any reconfiguration. You can, of course, tailor it a bit more to your needs.

    1. The script looks at a drive called 'Macintosh HD:Users:Tara.Brady:Movies' (you will need to point it to your own folder location) for any video files that have an extension of AVI or MKV (it even looks recursively through all subfolders), and also makes sure that the video has no label colour assigned yet. You’ll find out why the label colour thing is important in the next step.

    2. It loops through all of the files it found, and before it begins processing it sets the label colour of the file to grey. That way if you run multiple instances of this at the same time it will not process the same file twice. If you do run this multiple times, however, it only runs one instance of Handbrake at a time.

    3. It now runs the HandbrakeCLI using a set of parameters that I’ve found to work well using Front Row. You can configure the parameters to your liking using the information on this page. Also, it’s important to note that the command is run using “nice”, which will run the conversion process using low priority. That way it shouldn’t affect the overall performance of your system.

    4. It sets the label colour of the original file to green, which assuming the next step works will be worthless. It’s just good measure.

    5. The original file is deleted so that all you have left over is the MP4 version of the original video.

    6. That’s it. If any error occurs during the conversion process or on any of the other steps the label colour of the original file will be set to red. That way you’ll know something didn’t go as expected. Plus if the label colour is set to red the video will not be reprocessed if you decide to run the script again, unless you manually remove the label colour by right-clicking on the file.

    Download the script here:handbrake_conversion.zip

    Notes about the code:

    • You can specify any extensions you want to include in the conversion process, but it really only works with extensions that are 3 characters based on the way it generates the filename of the new path. I’m sure this can be improved, but I only wanted AVI and MKV files converted.

    • You’ll likely need to update the folder location that is searched. The way the path is specified is in an AppleScript format, and this may help you if you’ve never dealt with them before.

    • This is is assuming you’ve downloaded HandbrakeCLI and put it in the Applications folder.

    • You can use this with folder actions if you uncomment the first and last lines. Keep in mind that this enables it to run when a file is added to a particular folder, but will still process every matching file in that folder. It doesn’t actually use the items it is passed.

    • You can schedule this to run at certain times using iCal.

    There are probably much more elegant ways of doing this, but this works well for me. Hopefully this will at least point some of you in the right direction for customising your own script.
    Comments 8 Comments
    1. Biallystock's Avatar
      Biallystock -
      Isn't it better to simply install Perian, as converting the file will only degrade it?
    1. glacierdave's Avatar
      glacierdave -
      Quote Originally Posted by Biallystock View Post
      Isn't it better to simply install Perian, as converting the file will only degrade it?
      Only a good solution if you don't want to load it into iTunes, play it on an AppleTV or sync to an IOS device.

      But yes, if you're just looking to play on computer then Perian is the way to go.

      David
    1. fishbulb's Avatar
      fishbulb -
      Are the settings in the script anything like the Apple TV preset?
    1. moto51's Avatar
      moto51 -
      Rather than converting and taking up double the room (full quality for computer/tv and lower quality for iPod) I managed to get my hands on VLC before it was removed from the app store, I don't have to bother converting anything, instead I just drop them into VLC.
    1. dezinerau's Avatar
      dezinerau -
      Bially, you would convert in order to add the video to iTunes to copy to your iDevice or make available on your unhacked AppleTV.I have no quality issues when using handbrake to convert HD content either.
    1. jaswah's Avatar
      jaswah -
      Here's my alternative Apple TV Batch Encoder | jaswahSimply drop the files you want converted onto the droplet and it encodes using the Handbrake ATV2 setting.
    1. eds3028's Avatar
      eds3028 -
      An alternative that I use with very good success is a series of services and apps that will allow you to take any file format, from DVD's you buy now, to DVD's you may have converted in the past to .avi or .mkvGive it a go, works well for me, does the whole shebang including metadata and import to iTunes.How-To: Automating DVD & Blu-Ray (Backup, Encoding & Tagging) for Mac OS X - MacRumors Forums
    1. TaraB's Avatar
      TaraB -
      Quote Originally Posted by jaswah View Post
      Here's my alternative Apple TV Batch Encoder | jaswahSimply drop the files you want converted onto the droplet and it encodes using the Handbrake ATV2 setting.

      This is great!
  • New Forum Posts

    Jamesvdm

    Matching Zoo

    For the really little ones. It's just memory, with a couple of levels of difficulty.

    Plants vs Zombies

    What apps would you suggest to parents?

    Jamesvdm Today, 02:07 PM Go to last post
    TTGSteve

    In my small town, I’m basically known as “the computer guy”. Therefore, if it involves some sort of technology, I’m the go-to-guy for a lot of people.

    What apps would you suggest to parents?

    TTGSteve Today, 01:32 PM Go to last post
    swoffa

    Draw me something

    Random Photography Thread Version IV

    swoffa Today, 01:30 PM Go to last post
    Marcsteel

    I've been sharing my hotspot with my family who have an iPad 1 wifi only so they can access my 3G. As others have said, I have Telstra's 365 day prepaid

    iPad 4G is missing Personal Hotspot enablement

    Marcsteel Today, 01:25 PM Go to last post
    gehenna

    You mean an app you've developed?

    App Downloads

    gehenna Today, 01:08 PM Go to last post
    Mac Monk

    Hi All

    Does anyone know how to find out the total number of times your app has been downloaded since day one, going back two years?

    App Downloads

    Mac Monk Today, 12:52 PM Go to last post
    kyte

    Its looking good, and its very tempting, even for those of us who already have a K-5

    Pentax K-30 Camera - Hands-On Preview

    Pentax K-30 Official

    kyte Today, 10:55 AM Go to last post
    fulltimecasual

    Like i said on the podcast, sometimes its really handy.. Like if you're stuck in a long meeting without wifi and you need to use your laptop, or if you're

    iPad 4G is missing Personal Hotspot enablement

    fulltimecasual Today, 10:48 AM Go to last post
    kyte

    Sorry, Steve, I won't ship to the US. Craigslist was a washout, did a test ad for a small item and got idiots. I know it goes great in the US but it

    Best Place to sell Camera Gear

    kyte Today, 10:30 AM Go to last post
    kyte

    Been meaning to do this one for a long time. Olympus XZ-1 is a very competent little cam.


    Harry's Cafe de Wheels by kyte50, on

    Random Photography Thread Version IV

    kyte Today, 10:19 AM Go to last post