10.29.2009

Applescript, Quicktime, and the Flip Mino

Awhile back I bought a Flip Mino. If you haven't heard about it you can check it out here. I love this little video camera and it allows me to catch things on video in a fraction of the time of standard camcorders or digital cameras. Unfortunately that means I have waaaaay too many short little video clips clogging up my hard drive. I've been learning Adobe After Effects lately and thought I'd try my hand at combining some of these smaller clips into larger, more comprehensive videos for Youtube.

So I attempted to open my Flip videos (in .AVI format) with After Effects. No can do pal! For some reason (I'm assuming it is something with the codec used on the Flip Mino when recording) I can't bring these clips into either After Effects or Premiere. I don't know if anyone else has had this problem but it is very frustrating. In order to use videos from my Flip I have to use QuickTime Pro to export them to .mov files and then pull them into AE. This was too time consuming for me to deal with so I never bothered.

I've recently been learning Applescript and was looking for something to try my shiny new skills out on. This project reeked of repetition and was ripe for some Applescripting so I wrote the following script. It allows you to chose the video files you want to convert, then a destination folder for the exports. It loops through each video and exports it to said destination folder. Took me a few tries but it works. Check it:

-- Script written to convert Flip videos to QuickTime movies
-- Author: Zachary Abresch
-- Version: 0.1
-- URL: http://www.roundus.com
-- Blog: http://dorkequalsme.blogspot.com
-- Script wide variables
set sourceFolder to ""
set destinationFolder to ""

tell application "Finder"
 activate
 -- Select all videos to be converted
 set videoList to choose file with prompt ¬
  "Choose your videos" with multiple selections allowed
 -- Choose or create destination folder
 set destinationFolder to choose folder with prompt "Choose or create a destination folder" as string
 -- Loop through selected videos
 set vidCount to count videoList
 repeat with currentVideo in videoList
  set cv to (currentVideo)
  set cvName to name of cv
  set cvString to cv as string
  set output to destinationFolder & cvName as string
  with timeout of (100 * 60) seconds
   tell application "QuickTime Player"
    launch
    -- 1. Open video in Quicktime
    open cv
    tell document 1
     export as QuickTime movie to output using most recent settings
    end tell
    -- 2. Use menu command 'File > Export
    -- 3. Set Export type to "Movie to QuickTime Movie"
    -- 4. Set Use to "Broadband - Medium
    -- 5. Export to chosen destination folder
    close document 1
   end tell
  end timeout
 end repeat
end tell

Now this does assume you have Quicktime Pro installed but it works flawlessly. I have plans for integrating Growl notifications so I can let this run in the background. I also want to convert this to a droplet so I'll probably post updates here as I add features. If you are converting very large files you will want to change the timeout duration or the script will stop before the export completes. Let me know if anyone uses this or if you have any suggestions for my code. I'm fairly new to Applescript and wrote this whole thing in two or three Pomodoros.

I figure I'm going to let this thing run overnight soon and convert my entire Flip library. Then I can just run it whenever I import videos from the Flip. Maybe I'll even hook up some folder actions or get Hazel into the act to convert them auto-magically ...

If you liked this article let me know and I'll write more.

*** Update *** I recently ran this script while working on a project and noticed type of bug in the code above. On the line reading:

export as QuickTime movie to output using most recent settings

you can change it to use specific presets within the Quicktime instead of the last settings used. Since you can't depend on that staying the same it is more stable to specify the settings preset. You can also use a settings file. View the Dictionary for Quicktime to learn more. I've changed my local version of the script to have the line:

export as QuickTime movie to output using settings preset "Broadband - Medium"

and it works perfectly now. It was in my pseudo-code but never got translated into the actual script. I also removed a few lines in the code above that referenced variables that were no longer being used.

2 comments:

  1. I use something like this for same purposes but the annoying thing is that every time that quicktime opens a movie it starts bouncing on the dock. How we can avoid this and make it run completely in background

    ReplyDelete
  2. hmm … good question. I'm not sure I remember if Quicktime bounced or not. I think I had icon bouncing turned off system-wide but I've since upgraded to Snow Leopard and haven't tried this script yet. I'll try that this week and see if
    a) this post need an update and
    b) my Quicktime icon bounces.

    Thanks for the read!

    ReplyDelete

share

Bookmark and Share