0

I have an applescript used to create image sequences from videos. It works great for movies taken with my nikon camera. It creates a bunch of solid green images for movies taken with my canon camera. The weird thing is that if I use quicktime to export the image sequence manually it works fine (no green images). Only when run via the script does quicktime create the green frames (all green frames by the way).

Below is the code :

#set vFile to (choose file with prompt "Select a video file:")
on open of finderObjects -- "open" handler triggered by drag'n'drop launches
    repeat with vFile in (finderObjects) -- in case multiple objects dropped on applet
        tell application "Finder"
            list folder ":Library:QuickTime:Presets"
            set theList to result
            set qSet to (choose from list theList)
            set vBase to the name of vFile
        end tell

        tell application "Finder"
            if (folder ((path to movies folder as string) & "TLTemp") exists) then
                delete folder ((path to movies folder as string) & "TLTemp")
            end if

            if not (folder ((path to movies folder as string) & "TLTemp") exists) then
                set TLDir to make new folder at (path to movies folder as string) with properties ¬
                    {name:"TLTemp"}
            end if
        end tell


        #tell application "QuickTime Player 7" to open vFile
        tell application "QuickTime Player 7"
            open vFile
            set settings_file to (":Library:QuickTime:Presets:" & qSet)
            set TLtemp to ((path to movies folder as string) & "TLTemp:" & vBase)
            with timeout of 500 seconds
                export document 1 to TLtemp as image sequence using settings settings_file
            end timeout
            #export document 1 to TLtemp as image sequence

            close document 1
        end tell

        set the item_list to list folder ((path to movies folder as string) & "TLTemp:") without invisibles
        set pictureFile to ((path to movies folder as string) & "TLTemp:" & item 1 of item_list)
        tell application "QuickTime Player 7"
            activate
            open image sequence pictureFile frames per second 30
            set the looping of document 1 to true
            play document 1
        end tell



    end repeat
end open
tavis
  • 200
  • 2
  • 9

1 Answers1

0

I've never worked with image sequences, but I have an AppleScript that opens Finder's selected items in QuickTime 7 and captures 10 still images as PICT files. If you incremented the front document's current time by one frame (instead of duration / 11 as I did), could it help you?

--   Use iPhoto to convert these PICT files to PNGs.
set exportFolder to (path to the desktop as text) & "photos from QuickTime:"
set picturesPerVideo to 10



tell application "Finder" to set theSelection to the selection as list
repeat with i from 1 to (count of theSelection)
    set theItem to item i of theSelection
    tell application "Finder"
        set finderPath to (file (theItem as text))'s POSIX path
        set theName to theItem's name
        open theItem using (path to application "QuickTime Player 7")
    end tell
    set theCurrentDate to current date
    tell application "System Events" to set process "QuickTime Player 7"'s visible to false
    tell application "QuickTime Player 7"
        repeat until front document's path = finderPath
            if ((current date) - 15) > theCurrentDate then error "Timeout."
            delay 1
        end repeat

        repeat with j from 1 to picturesPerVideo
            set timeInVideo to j / (picturesPerVideo + 1)
            set front document's current time to (front document's duration) * timeInVideo
            set exportPath to exportFolder & theName & "_" & j & ".pict"
            export front document to exportPath as picture replacing yes
        end repeat
        close front document
    end tell
end repeat

And sorry for the late answer. I just came across your post.

John Sauer
  • 4,411
  • 1
  • 25
  • 33
  • This doesn't solve my problem because the problem occurs during the quicktime export process. iPhoto doesn't have the capability to export frames from video files. – tavis Mar 22 '13 at 23:40
  • I use QuickTime 7 to generate .PICT images, then use iPhoto only to convert them to a different image format. Are you saying that the above AppleScript produces solid green images for you? Could you give me a video of snippet of yours for me to test? [The script works for me.](http://dl.dropbox.com/u/475192/2013_03_22.mov) – John Sauer Mar 23 '13 at 01:11
  • The script works for videos taken with a nikon camera. But with my canon powershot i get all solid green images when doing a image sequence export. – tavis Apr 01 '13 at 03:10
  • Can you share a short video from your Nikon camera? – John Sauer Apr 01 '13 at 12:09
  • What settings does `settings_file` provide? Is it necessary? I used `export front document to filePath as image sequence` to generate 600 PNGs from your Nikon video, and none were green. If you open nikon_video in QuickTime Player 7 and run [this script](http://i.stack.imgur.com/rbKQd.png), do you also generate normal PNG images? Are QuickTime "image sequences" supposed to be a folder containing image files (as I'm seeing now), or a single file of some kind? – John Sauer Apr 02 '13 at 03:09
  • PLEASE READ MY ORIGINAL POST. The nikon movies work fine. It's the videos from the CANON camera that produce green images. – tavis Apr 07 '13 at 01:28
  • Give me some slack. I first responded to this question 10 weeks ago, and you didn't reply for 2 months. Did you try the AppleScript from my previous comment? [It works with both videos.](http://dl.dropbox.com/u/475192/14298856.mov) – John Sauer Apr 07 '13 at 02:34
  • Your approach does work for the canon movies. however it is much too slow to use for timelapse movies for which I export hundreds of frames per movie. Thanks trying though, I do appreciate it. – tavis Apr 08 '13 at 01:50
  • I've solved this problem by using an ffmpeg shell command if the video is of the canon variety. – tavis Apr 08 '13 at 20:05