Wednesday, December 23, 2009

For a long time I have wanted a droplet for exporting QuickTime files. That is to say I wanted an icon on my desktop that I could drop video files into and it would export them with custom settings from QuickTime Pro. Many times have I started a search looking for Quicktime droplets, but I never could find anything. Well, due to some extra time recently, I was able to get down and dirty with some AppleScript to get it done!

Note: I owe many thanks to the help I received online for this, mainly this post from which I have copied (word for word) parts of to help with this post. To the others that helped: Thanks!

Note 2: Sorry Windows users, this is OS X only. These scripts require QuickTime Pro ($30), which allows you to export videos from QuickTime. If you are on Snow Leopard, you have to have QuickTime 7 installed for this to work.

Note 3: I know that not everyone is a scripting pro... I know for a fact that I am not! So I have tried to make this walkthrough as simple language as possible. You need NO experience in any form of scripting to get this to work, but you will need the ability to comprehend what is going on. Just follow the directions and you will be fine. For those pros out there: Feel free to glean what you need while ignoring the rest!

Step 1: Retrieve the export settings from QuickTime.

1) Open a movie representative of the kind you'd like to export in QT.
2) Choose "Export" from the "File" menu
3) Select the desired export kind from the "Export:" popup menu (I always use "Movie to QuickTime movie", using something different may not work with this setup)
4) Click the "Options..." button to specify your custom settings, then click OK
5) Note that the "Use:" popup menu now displays "Most Recent Settings"
6) Start the export by clicking on the "Save" button (if you don't start an export the "Most Recent Settings" won't stick)
7) Cancel the export if it is a long one
8) Leave the video open in QT as we move on...

At this point you are ready for some AppleScripting. Open your Application folder, then open the Utilities folder. Find "AppleScript Editor" and open it. Copy and paste the below text into the window that pops up:

tell application "QuickTime Player 7"
tell first document
save export settings for QuickTime movie to file "Macintosh HD:Users:Matthew:Documents:QuickTime Scripts:Export.set"
end tell
end tell


Note that this is MY snippet of code, you will need to make it work for you. There is one thing that you may need to change, and one thing that you will need to change:

tell application "QuickTime Player 7": Leopard (and below) users will need to change this to "QuickTime Player. Snow Leopard users leave this as "QuickTime Player 7".

save export settings for QuickTime movie to file "Macintosh HD:Users:Matthew:Documents:QuickTime Scripts:Export.set": This sets where your setting file will be saved. Remember that this file will have to be stationary for the life of your QuickTime Droplet, so choose a place where it won't get in the way. (IE: on your desktop is a BAD idea!) Note that I have created a folder named "QuickTime Scripts" in my "Documents" folder. After you have decided where you want your export file(s) to reside and you have created the necessary folders, update the script to reflect where you want them. IE: Change "Macintosh HD:Users:Matthew:Documents:QuickTime Scripts:Export.set" to wherever you want it to save. Also, change Export.set to name of what you want the file to be.

NOW it is time to run the script! On the top of the AppleScript Editor window, click "Run". If everything is good then it will look like nothing happened right away, but if you open the folder where you told the file to say you will see the file: "Export.set" (or whatever you said to save it as). (If things don't go according to plan and you get an error, try to figure out what happened. Go back and read the steps and make sure that each step was done correctly. If you are still having problems, contact me and I will try to help out.)

So, after all of that work we have a single simple file. If you have more than one droplet you would like to create, feel free to repeat the above steps for as many droplets you would like. Also, save this script so that you have access to it later. Now, on to...

Step 2. In this step we will create the actual droplet file.

In AppleScript Editor, create a new script and paste in the following code:

on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
tell application "QuickTime Player 7"
open this_item
get name of the front document
with timeout of 36000 seconds -- 10 hrs timeout
export document 1 to "Macintosh HD:Users:Matthew:Desktop:" & name of the front document as QuickTime movie ¬
replacing no using settings "Macintosh HD:Users:Matthew:Documents:QuickTime Scripts:Export.set"
end timeout
close front document
end tell
end repeat
tell application "QuickTime Player 7"
quit
end tell
display dialog "Your Encoding is done!" buttons {"Thanks a bunch!"} default button 1
end open


Once again there are several things that you will need to change for this to work on your machine:

tell application "QuickTime Player 7": Remember that you may need to change this to "QuickTime Player" if you are not on Snow Leopard.

with timeout of 36000 seconds -- 10 hrs timeout: Currently it is set to timeout after 10 hours. This means that at the 10 hour mark whichever video is being exported will finish, but any additional videos will not start encoding. If you export lots of large files, you may need to bump this number up a bit, otherwise leave it alone.

export document 1 to "Macintosh HD:Users:Matthew:Desktop:" & name of the front document as QuickTime movie ¬: Change this to where you would like the file to save to. It is currently set to save to my desktop.

replacing no using settings "Macintosh HD:Users:Matthew:Documents:QuickTime Scripts:Export.set": Change this to where you saved the export file in Step 1. Feel free to copy and paste from the script in Step 1.

display dialog "Your Encoding is done!" buttons {"Thanks a bunch!"} default button 1: This is a dialog box that says "Your Encoding is done!" whenever the encoding is done. Feel free to delete this line if you don't want a dialog box.

Now, DON'T Run this script! If you do, nothing will happen. Remember that we are creating a droplet, which is (technically) an application. So (after saving the script for future reference) go to "File>Save As...", type in the name you want for your droplet, and change the "File Format" to "Application". Also, check the "Run Only" box. Now click "Save", and you are done!

Feel free to test out your droplet. Quit QuickTime (if it is still open), grab a few video files in the finder, and drag them onto the top of your droplet. QuickTime should open and start exporting your video files. When it is done it will quit QuickTime and show you a dialog box saying it is done.

Well, there you go! Have fun playing around with AppleScript, the possibilities are endless! For example, you can set it up so that you have a "Hot Folder", and any video dropped into said folder is automatically exported. (See this post for help on that.) Because I have 7 export settings I want to manage, I am now off to work with the "display dialog" tag and compress all seven export settings into one droplet which will ask the user which export setting they want to use.

Hope this helps! If you were successful in getting this to work, let me know by posting a comment! Know of a way I could write this tutorial better? Let me know!

Matthew


 

Copyright 2006| Blogger Templates by GeckoandFly modified and converted to Blogger Beta by Blogcrowds.
No part of the content or the blog may be reproduced without prior written permission.