Random help with QuickTime script

Hey all,

I have enough background in coding to get me in trouble (a few classes on C++ in high school and college). I have no training in AppleScript, I have only played around with it a bit (mostly through trial and error).

I have mashed together two scripts with the idea of creating a QuickTime Export Droplet. IE: Running these scripts will create a file that I can drop a video file on and it will export them with given settings in QuickTime. I have everything working, but there are still a few bugs in the system that I would like some help with.

Note: I am on Snow Leopard, so I reference “QuickTime Player 7”. Users on Leopard probably need to change it to “QuickTime Player”. And, of course, I can export video because I have QuickTime Pro.

My first script tells QT to save the current export settings:

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

(This code is derived from this page, which has a good walkthrough of how this code has to be preset before use. Basically, open a video file, tell it to export with the settings you want, then with the video still open in QT run the AppleScript.)

Once I have the export file, I save this script as an application to create the droplet:

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
			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 tell
	end repeat
end open

Now I just drop files on the application and it exports it! Whoo hoo, it works!!!

But as I said, there are a few bugs with the script. Such as:

  1. If the video(s) don’t all export within a few minutes, the “application” comes up with an error: “AppleEvent timed out.” The currently exporting video will complete, but any videos that were in the queue won’t. This is bad, because sometimes I want to export 4 videos that all take 10+ hours to export. How can I make it never time out?

  2. When I open QT7 manually it brings up a “Welcome to QuickTime” window. Similarly, when I run my application this window pops up behind the first encoding video. This is a minor hassle, but is there a way to close this window?

  3. Also, when QT7 is done exporting each video clip, the video clip stays open. What line of code do I add at the end to close the current document?

  4. When I manually open QT7 and tell a video to export, it brings up another window with the exporting status. However, when I run my application, it doesn’t bring up a separate window, it attaches a progress bar to the video window (much like the “Save” dialogue box is attached to windows). I prefer the free floating window. Is there any way to do this?

There are a few things I would like the application to do that it currently doesn’t do (like quit QT7 after it is done, show an “Exporting Complete” message when done, not have an icon in the dock while running), but I feel like it is my job to figure out how to do those things on my own instead of badgering you to tell me how to do them. =: >

Anywho, thank you so much for your help! I fully value the time that you help me with this! Thanks again!

Matthew

Model: 1st gen Intel iMac
AppleScript: 2.1.1
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)

Hi,

I don’t have QuickTime 7 but I could help you with the first 3 questions

  1. insert a timeout block
  2. in QuickTime Player Preferences > General uncheck “Show Content Guide automatically”
  3. insert a close line

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"
			open this_item
			get name of the front document
			with timeout of 72000 seconds -- 20 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
end open

  1. Thanks!
  2. Thanks!
  3. Thanks!

I appreciate it!

Matthew