Skip to content

Apple TV Batch Encoder

Download the latest version of the Apple TV Batch Encoder for HandBrake

Updated for Lion.
Apple TV Gen2 – Batch Encoder v0.3

Changes:

  • Lion support.
  • Supports Apple TV (gen 2), iPad 2 & iPhone 4.
  • All prompts for priority etc have been removed.
  • Runs in high priority mode only.
  • Commas and apostrophes in filenames should now be OK.

This is just an AppleScript app so it’s super simple, but i’ll add in some additional control if people are interested.

Usage

To encode files, just select the ones you want to encode in the finder, and drag onto the “Apple TV Batch Encoder” app.

Requirements

You will need to download the latest HandBrake CLI (0.9.5) and it must be placed in your /Applications folder.

Features

Files are encoded using the HandBrake default Apple TV preset. Files currently encoding are give an orange label, files that encode successfully are given a green finder label. Files that fail are given a red label.

Limitations / Issues

Tagging?

Once i run my files (mkv/avi etc) through this i then use iDentify 2 (which is AWESOME) to tag all my files. Support Justin and pay for the app cause it’s definatly worth it.

Share this with some punks:
  • Twitter
  • email
  • Facebook
  • Tumblr
  • Posterous
45 Comments
  1. Squozen permalink

    Nice work, thanks for putting it out there – I’ll be making
    some tweaks and passing my changes back.

  2. Squozen permalink

    Another suggestion – if there is an error, instead of just flagging the failed file with a red label, add comments to the file’s spotlight comments field with more info.

    I might add this myself, though I expect the only error that should really happen is running out of disk space or the user moving a file during the encode.

  3. Steve b permalink

    Hey Jaswah,
    Is there any way to set the convert to a user defined preset ?
    I know that the Apple > Atv preset would be fine, But I have made my own presets and would prefer to batch them on that ?
    Steve’s Atv
    Steve’s iPhone
    Steve’s iPad
    Cheers,
    Steve

  4. Jason permalink

    Hey Steve, the easiest way is to ‘Show Package Contents’ and edit the main.scpt, changing ‘Apple TV 2′ to your preset name.
    Will have a think about a good way to implement this in a GUI. Thanks!

  5. Jason permalink

    Cool sounds good… will add it to the list :)

  6. Squozen permalink

    After:

    –Tag file with green label
    set label index of oneItem to 6

    I added:

    –add Spotlight comment to allow easy search and deletion later
    set comment of oneItem to “Encode_Success”

    This allows a Spotlight search to easily find any converted sources that you might want to delete to free up HD space.

  7. Squozen permalink

    Something like:

    choose from list {“AppleTV”, “iPhone”, “iPad”} with prompt “Choose encode type:”

    …should work, but if you have a modern AppleTV/iPhone, the AppleTV 2 encode should work on all these devices as they’re using the same decoding hardware.

  8. Squozen permalink

    Replying to myself:

    This works –

    set myOptions to {“AppleTV”, “iPhone”, “iPad”}
    set encodeType to (choose from list myOptions with prompt “Choose encode type:”)

    Then just add an if-then-else-endif section below. Should be fairly straightforward.

  9. Jason permalink

    Looks good, the only issue is that it’d be better to retrieve the list of built-in and user-defined presets to populate that list… wish i wasn’t so busy today so i could investigate!

  10. Steve b permalink

    Hey Jaswah,
    I have an Intel Mini running 0.9.5, and the Gen1 Script doesn’t seem to state Apple, Tv or Apple Tv anywhere in the main.script. I even cut and paste it out of applescripteditor into text edit and ran the find in there, I apologise, My noobness has overcome me.
    Steve

  11. Jason permalink

    Ahhhh of course… the gen 1 script i modified so that it doesn’t scale 720p content down (by default it downscales to 960×540 i think). to make your own presets work, this should work:

    set ConvertMovieCmd to “/Applications/HandBrakeCLI -i ” & sourceFile & ” -o ” & tmpFile & ” –preset=\”Steve’s Atv\” ;”

    (make sure you change in both places)

  12. Steve b permalink

    Also, when I dumped a recent avi into the script, it came up as red labelled with no reason. Anything look wrong ?

    Could it be that the Gen2 code is in the Gen1 script ?
    cause I don’t have an Atv2 preset it is failing ?

  13. Steve b permalink

    [IMG]http://i5.photobucket.com/albums/y169/devilrolla12345/823e0d53.png[/IMG]

  14. Jason permalink

    not too sure… what is the full path to the file… at the moment it craps out on single quotes if they’re in the filenames.. could that be it?

  15. Steve b permalink

    no quotes in the filename at all:
    tried another one, failed first time as well.
    The “downloaded” file is on an external usb drive, and handbrake converts to another folder on the same drive.

    http://s5.photobucket.com/albums/y169/devilrolla12345/?action=view&current=1c47a19b.png

  16. Squozen permalink

    Yep, you’d need to parse ~/Library/Application Support/Handbrake/UserPresets.plist and strip the PresetName field followed by the for the name. Shouldn’t be too hard to do, but adding all these features makes it feel a bit like you might as well just launch the Handbrake GUI. :P

  17. Squozen permalink

    Does it work if you put the file to be encoded on the desktop?

  18. Jason permalink

    yeah, only prob is that list doesn’t include built in presets, does it?

  19. Jason permalink

    yes, try on the desktop, or try renaming to remove all the fullstops, see if that helps….

  20. Squozen permalink

    I’ve tested files with multiple fullstops, so that won’t be it. I’d guess it’s the external volume or the Handbrake CLI app is missing.

  21. Steve b permalink

    Moved the file to the desktop, same problem.
    Removed the fullstops, same problem.

  22. Jason permalink

    Have you definitely added BOTH the HandBrake.app and ‘HandBrake CLI’ to your /Applications folder?

  23. Steve b permalink

    where is the CLI ?

  24. Steve b permalink

    1,000,000 apologies.
    noob.com,
    ~Steve

  25. Squozen permalink

    I’m tempted to repack the droplet with the CLI app inside it. :)

  26. Steve b permalink

    I give up. lol
    CLI is loaded and Handbrake are loaded in the /App folder
    Now it labels the .avi as orange, but doesn’t move.
    Does Handbrake need to be opened or closed.
    *shrugs*
    Sorry for the stuff around.
    ~Steve

  27. Jason permalink

    it will take quite some time to encode. just be patient and it will happen :)

  28. Jason permalink

    even better idea :)

  29. Steve b permalink

    I quit it, and restarted it.
    After I quit it the 2nd time, my CPU was @ 97%.
    Handbrake CLI was running twice and using it all up.
    Even after I force quit it two separate times.
    ~Steve

  30. Jason permalink

    you have to force quit HandBrake CLI with activity monitor. The droplet and the the HandBrake CLI are completely independent.

  31. Steve B permalink

    Ok, I’m back.
    CLI loaded, works a charm. Just encoded a file then, brilliant.
    There are some things that could make this action super badass.

    1. Included the CLI in the download
    2. Have a “watch folder” that the user can select.
    ( I have a watch folder for transmission, so if I could download with it, the finished file ends up in a folder that your script see’s, then it can pickup that file and encode it all on the fly. )
    3. Have a destination folder for the finished encode. ( user: Pick export folder etc )

    Seriously cool little app mate. I got it working on my external drive as well.

    THANK YOU !

  32. Steve b permalink

    On a side note. I have switched from handbrake 0.9.4 to 0.9.5 and from MetaX to Identify2 (paid).
    When I use the batch script, and then identify2 the file plays and then stalls on my atv ( then I have to reset the atv because it crashes )
    Running the file through Handbrake ( no CLI ) and then Identify2 and the file works fine.
    I tried playing the file on my mac mini with no issues, but on my gen1 Atv its crashing.
    I also turned OFF optimise files on Identify as there should be no issue with a fresh m4v from handbrake.
    Cheers,
    ~Steve

  33. Steve b permalink

    Confirmed on 2 files.
    CLI handbrake – Crashed file
    Hanbrake – No crashed file.
    ~Steve

  34. Jason permalink

    Does the file play ok if you don’t run it through iDentify first?

  35. Steve b permalink

    CLI – Crashes
    Handbrake – No crash.
    Both done with Identify.

    In the main script, you have decomb on, is that correct ?
    Steve

  36. Jason permalink

    sounds weird. have you got perian installed?

  37. ChrisH permalink

    I love that you’ve put this together, Jaswah. I’m struggling to understand why it asks the user to manually answer the priority call and to then acknowledge the encode completion.

    I’m trying to use Hazel to move the completed files from the source folder to a second folder where iDentify 2 can tag them, having been newly converted from .avi to .m4v

    Though Hazel starts the first encoding, it’s abruptly halted until I respond to the priority call. Once it’s done encoding, the completion dialog appears and no further encodes are initiated from the aforementioned source folder.

    And since I’m already over my head with the Automator actions, how do I get your application to move the finished .m4v files to my destination folder:
    /Users/ChrisH/Movies/Identify

  38. Jason permalink

    Chris if you view the package contents you can find an AppleScript file which you can remove the dialogs from. You could also specify a different output location.

    The priority setting is so can keep working while encoding.

  39. Jason, I want to thank you for doing such a great job with this script. I have over 2 TB of avi and mkv files that I was going to give up on trying to stream to the tv’s in my house. This has been such a timesaver, I’ve converted about 1.5 TB’s so far. Again thank you.

    I have run into a problem after upgrading to Lion, it just doesn’t work. I was wondering if you or any other users have come up with a solution.
    In the meantime, I have both my machines running my original Snow Leopard builds so that I can keep converting.

    Thanks for any help.

  40. Jason permalink

    Hey mate. Glad to help!! You’re in the exact same boat that I was in.. the reason for making this script.

    I’ve created a Lion compatible version… will upload soon.

    EDIT: New version uploaded. Enjoy :)

  41. Jason, I can’t thank you enough. The new version works perfectly. I’m one more step to a permanent Lion install.

  42. Joe A permalink

    Jason, thanks so much for this. It has made my life so much easier! I was reading the thread and read your comment about setting a destination folder. I opened the script editor and I think I know which line you are talking about but I’m not quite sure I know what exactly I’m supposed to edit (my first time with scripts) Any help would be much appreciated. I want to set the destination folder to be my automatically add to iTunes folder.

    This is the line, right?

    set destFold to quoted form of POSIX path of (container of itemProp as alias)
    –what the name of the file is

    –set extension hidden of oneItem to true

    Thanks in advance for the help.

  43. shane permalink

    Jason, this is perfect!

    im wondering if its possible to have it allow you to add more things to the queue while it is already encoding?

    thanks,

    shane

  44. End User permalink

    Hi, this script sounds great, but I get this error when I try to use it:

    “Finder got an error: Network File Permission Error.”

    The source video is located on my hard drive.

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS