Quicktime applescript for hire.

Any suggestions on where I can go to get an applescript made for the following tasks? I’m an editor and I work in animation and deal with tons of Targa sequences. I’m trying to make life a little easier and don’t know applescript well enough to achieve what I want to do.

  1. I would have approximately 300 folders within a folder TOONCITY on my desktop. Each folder would be numbered scene-001, scene-002 etc. Within each of these folders is an image Sequence (targa sequence). I want to have an applescript that I can drop all of these folders with image sequences onto and it will launch quicktime 7, open each image sequence, save each image sequence individually as a self-contained quicktime with the original Folder’s name ( scene-001, scene-002 etc.) at 24 frames per second back onto my TOONCITY folder on the desktop.

  2. That’s the main applescript I’m looking for. What would be REALLY great if there was a way to add to it the ability to create a ‘slate’ with text of each folder number ( scene-001, scene-002 etc.) that lasts for 8 frames placed at the beginning of each of these self contained quicktimes. After the 8 frame slate the regular targa sequence would begin. This ‘slate’ would need to be the same aspect ratio as the targa files.

thanks,
chris
zeus100@mac.com

Model: G5 2.7ghz
AppleScript: 2.1
Browser: Safari 412
Operating System: Mac OS X (10.4)

Do you targe image files have a file name extension?
If so what is the extension?

Do your targa files contain a alpha channel (transparency)?
Do your sequences start with 0 or 1?
What do your targa image file filenames look like? (“image0001.targa”) a few examples would help.

What is the dimensions of your targa images?

I should be able to put together a script for you that uses iMagine Photo (free) to do everything you want.

Kevin

The base script exists to do this exist already;
http://www.apple.com/applescript/quicktime/

*Create Slideshow From Folder - Drag a folder of images onto this droplet to create a slideshow movie file. Options include: making the file self-presenting and self-closing, auto display of images (movie mode) or manual advancing (slideshow mode), seconds per image or images per second, and saving the file as a proxy linked to the images or as self-contained.

The text can be added via script as well; This should take a few mods to customize, but you can play with the droplet to see how it works. You can double click “Slideshow from Folder” to bring up the preferences to save as self-contained movie with desired FPS.

I’ll spend some time with this, it shouldn’t take too much time.
SC

You will need to edit the properties at the beginning of this script to be appropriate for your own file names (pFilenamePrefix and pFilenameExtension will both need to be changed plus pNumDigits in your file name). I have given this script the barest of testing.

if pNumDigits is equal to 5 then your filenames will look like:

scene-00001.targa

if pNumDigits is equal to 4 then your filenames will look like:

scene-0001.targa

I hope this helps.

Kevin


property pFrameRate : 24
property pFrameDuration : 600 div pFrameRate
property pMovieCompressor : "Sorenson Video 3 Compressor"
property pNumberOfSlates : 8
property pFilenamePrefix : "scene-" -- "DSCN"
property pFilenameExtension : ".targa" -- ".JPG"
property pSlateFont : "Verdana"
property pSlateFontSize : 24 -- overridden in code further down 1/16 of the height of the frames.
property pSlateBackColor : {0, 0, 0} -- black
property pSlateTextColor : {65535, 65535, 65535} -- white {red, green, blue}
property pNumDigits : 5
property pShowFrames : true -- false is faster but you cant see the progress of the frames being processed.

on run
	set topFolder to choose folder with prompt "Choose folder containing folders of movie frames: "
	set folderList to list folder topFolder without invisibles
	set myList to {}
	repeat with j from 1 to the number of items in folderList
		if the first character of (item j in folderList) is not "." then
			set tempItem to (topFolder as string) & (item j in folderList) as alias
			if folder of (info for tempItem) is true then
				set end of myList to tempItem
			end if
		end if
	end repeat
	repeat with theFolder in myList
		ProcessFolder(theFolder)
	end repeat
end run

on CreateGraphicDocument(theWidth, theHeight)
	tell application "iMagine Photo"
		if pShowFrames is true then
			return make new window document with properties {dimensions:{theWidth, theHeight}}
		else
			return make new graphic document with properties {dimensions:{theWidth, theHeight}}
		end if
	end tell
end CreateGraphicDocument

on ProcessFolder(theFolder)
	-- first up determine dimensions of targa files.
	--find the dimensions of the first image file and assume all others are the same.
	set theInfo to (info for theFolder)
	set folderName to name of theInfo
	set folderPath to theFolder as string
	set firstFile to missing value
	set filePathName to missing value
	try
		set filePathName to folderPath & pFilenamePrefix & my add_leading_zeros(1, pNumDigits - 1) & pFilenameExtension
		set firstFile to filePathName as alias
	on error
		display dialog "File doesn't exist: " & filePathName
		return
	end try
	tell application "iMagine Photo"
		set thisImporter to import graphic firstFile
		if the component error of thisImporter is not equal to 0 then
			close thisImporter
			display dialog "Error importing initial frame file: " & filePathName
			return
		end if
		set {x, y, theWidth, theHeight} to the natural bounds of thisImporter
		close thisImporter
		set pSlateFontSize to theHeight div 16
		set thisDocument to my CreateGraphicDocument(theWidth, theHeight)
		set movieEditor to make new movie editor with properties {dimensions:{theWidth, theHeight}}
		set the data compressor of movieEditor to pMovieCompressor
		set the export compression quality of movieEditor to high
		tell thisDocument to create composition element with properties {class:filled rectangle, color:pSlateBackColor, bounds rectangle:{0, 0, theWidth, theHeight}}
		tell thisDocument to create composition element with properties {class:standard text, font:pSlateFont, font size:pSlateFontSize, start from:centre, start point:{theWidth div 2, theHeight div 2}, color:pSlateTextColor, background color:pSlateBackColor, drawing text:folderName}
		set export folder location of movieEditor to theFolder
		set export file name of movieEditor to (folderName & ".mov")
		set editing of movieEditor to true
		repeat with i from 1 to pNumberOfSlates
			tell movieEditor to append sample with properties {source document:thisDocument, sample duration:pFrameDuration, source rectangle:{0, 0, theWidth, theHeight}}
		end repeat
		set maxPossFrames to (10 ^ pNumDigits) - 1
		set theFile to missing value
		repeat with i from 1 to maxPossFrames
			set filePathName to folderPath & pFilenamePrefix & my add_leading_zeros(i, pNumDigits - 1) & pFilenameExtension
			try
				set theFile to filePathName as alias
				my ProcessFile(theFile, thisDocument)
				tell movieEditor to append sample with properties {source document:thisDocument, sample duration:pFrameDuration, source rectangle:{0, 0, theWidth, theHeight}}
			on error
				exit repeat
			end try
		end repeat
		set editing of movieEditor to false
		export movieEditor
		close movieEditor
		close thisDocument
	end tell
end ProcessFolder

on ProcessFile(theFile, theDocument)
	tell application "iMagine Photo"
		set thisImporter to import graphic theFile
		if the component error of thisImporter is not equal to 0 then
			close thisImporter
			display dialog "Error importing frame file: " & name of (info for theFile)
			return
		end if
		set the drawing destination of thisImporter to theDocument
		draw thisImporter
		close thisImporter
	end tell
end ProcessFile

--For example, if the maximum number of leading zeros is set to 2, then the 
--results will range from 001 to 999. If the maximum number of leading zeros
--is 3, then the  results will range from 0001 to 9999, and so on.

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
	else
		return this_number as text
	end if
end add_leading_zeros


Wow Kevin,

This works really great. Incredibly good job. I’m learning alot from your script.

HUGE thanks.