Quicktime export


In the continuing saga, the following code doesn’t produce the sequence of frames:

tell application “QuickTime Player”
if (can export movie captured_movie as image sequence) is true then
export movie captured_movie as image sequence using default settings
close movie captured_movie
end if
end tell

“captured_movie” is the name of the movie. Quicktime activates, an empty movie appears but nothing else happens. I’ve tried different approaches but the results are always the same. Any ideas?



iMagine Photo is a tool for processing image files and movie frames using AppleScript. It is free. To use the following script which can do what you ask you will need to download iMagine Photo:


property baseFileName : "Image"

on run
	tell application "iMagine Photo"
		set thisFile to choose file with prompt "Select a movie file: "
		set theFolder to choose folder with prompt "Select a folder where you want to save the image files:"
		set thisMovie to import movie thisFile
		set {x, y, xDim, yDim} to the natural bounds of thisMovie
		set thisDocument to make new window document with properties {dimensions:{xDim, yDim}}
		set the drawing destination of thisMovie to thisDocument
		set current time of thisMovie to 0
		set the top left point of thisMovie to {0, 0}
		set the export file type of thisDocument to "JPEG"
		set the export folder location of thisDocument to theFolder
		set frameNumber to 1
			draw thisMovie
			set imageFileName to baseFileName & (my add_leading_zeros(frameNumber, 5)) & ".jpg"
			set the export file name of thisDocument to imageFileName
			export thisDocument
			set frameNumber to frameNumber + 1
			set nextSampleTime to the next video sample of thisMovie
			if nextSampleTime is equal to -1 then
				exit repeat
			end if
			set current time of thisMovie to nextSampleTime
		end repeat
		close thisMovie
		close thisDocument
	end tell
end run

on add_leading_zeros(this_number, max_leading_zeros)
	set the threshold_number to (10 ^ max_leading_zeros) as integer
	if this_number is less than the threshold_number then
		set the leading_zeros to ""
		set the digit_count to the length of ((this_number div 1) as string)
		set the character_count to (max_leading_zeros + 1) - digit_count
		repeat character_count times
			set the leading_zeros to (the leading_zeros & "0") as string
		end repeat
		return (leading_zeros & (this_number as text)) as string
		return this_number as text
	end if
end add_leading_zeros

iMagine Photo is terrific and it’s amazing that it’s now free. Way to go ktam! However, if you are keen on doing this all in QuickTime Player, here’s code that works for me:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

The script I have so far (see below) does NOT give consistent results. Sometimes the folders do not get created sometimes Quicktime does not launch. The movie NEVER gets opened in Quicktime. The capture folder and output folder are on the desktop. The script is attached to the capture folder. The resulting folders and files are created in the output folder. After a few times of testing I have to log out and then log back in again on order to get the script to run (ie. Quicktime stops launching). I am using 10.3.8 and AS 1.9.3. I suspect I am missing a few things but I am not sure what. Any ideas? Thanks for everyone’s help so far. BTW, the error dialog does not appear. You welcome to try the script. Create two folders on the desktop. One called “capture folder” and the other “output folder”. Attach the script to “capture folder” and then drop a Quicktime movie on to the capture folder.

This script works for me as a Folder Action on Mac OS X 10.3.8:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]


I have given up. Apparently, AS is not what we are looking for as a useful tool. To do something simple involves so much work it defeats its own purpose. The concept of AS is sound but its execution is very flawed. It will be MUCH FASTER to have the user manually export the audio and frames than to write this script. Anyway, thanks for your help Jonn8.

BTW, the script puts the frames into the capture folder not the output folder. So, I changed the line:

set captured_movie_folder to (make new folder at folder c with properties {name:n}) as Unicode text


set captured_movie_folder to (make new folder at folder “output folder” with properties {name:n}) as Unicode text.

This made the script very upset and refused to output anything.

It took me about 10 minutes to write that script and, as I said, it works perfectly for me. I assumed that the exported image sequence was meant to go in the “frames” folder. Is this not the case?

If you attach this Folder Action to a folder and then drop a .mov file into the folder to which it is attached, this script will create a new folder in the drop folder with the name of the file (minus the extension). Inside this folder will be two subfolders, “frames” and “audio”. The movie will then be opened and exported as an image sequence with the individual frames saved in the “frames” folder (frames_folder). And finally the movie will be closed. Adding audio export is trivial. If you want the new folders (captured_movie_folder and its subs) created someplace other than the drop folder, that’s trivial as well:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

I wouldn’t be surpised if the problem is with the folder action rather than the AppleScript apart from where you changed one of Jonn’s lines of code. How does finder expect to know where “output_folder” is on your hard disk. When you do something like that you have to specify the full path to where that folder is.

The problem with folder actions occurs when you are copying large files into the folder with the folder action. If the folder action triggers before the file has been completely written and you then ask Quicktime Player to process an incomplete file it is no wonder that Quicktime player then has problems and then no doubt your applescript as well.

This problem does not happen if you are just moving files on the same hard disk. However it shows itself when you are copying large files (10s of Megabytes) all on you local hard disks, and is a significant problem for much smaller files if the file is being copied over a network. The worst thing about when file copying occurs over the network, is the file is repeatedly opened, written to and then closed until the full file transfer is complete. This makes it difficult to determine when the transfer is complete and you can only do something like repeatedly checking the file size and if it has stayed constant for a minute or so then you are probably safe.

Since you haven’t specified where your files are being copied or moved from with the folder action we can’t know if this is your problem.

Automated processing where you need to control the actions of applications like “Quicktime Player” is what AppleScript does well, AppleScript definitely has weaknesses but doing this sort of task is not one of them.



The folders reside on the same machine. I have setup the capture folder and the output folder on the desktop. The capture folder has the script attached. The script creates the appropriate folders inside the output folder and exports the sequence of frames and audio file to the created folders inside the output folder. Right now, my testing of the script involves dragging and dropping a Quicktime movie on to the capture folder. The folders are created okay, Quicktime does start up (most of the time) but the movie doesn’t even appear in a movie window. My guess would be that the movie name/path is being munged somehow and so Quicktime can’t open it. The statement: “if (can export captured_movie as image sequence) is true then” doesn’t get executed.


ol’ scripter

Um, what? You first say that it works (the first sentence I quoted is exactly what the script is supposed to do) and then you say it never opens the movie. If it didn’t open the movie, there would be no way for it to export the frames and audio. Which is it?