Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

physaux

macrumors newbie
Original poster
Feb 11, 2010
7
0
I am trying to set a variable that will hold the length of a movie in quicktime.
Here is my try at it:

tell application "QuickTime Player"
set movie_length as ??????????

How do I do that??? Pleaaaase help me!
 
I am trying to set a variable that will hold the length of a movie in quicktime.
Here is my try at it:

tell application "QuickTime Player"
set movie_length as ??????????

How do I do that??? Pleaaaase help me!

AppleScript is fairly forgiving when it comes to assigning variables.

set movie_length to 120 -- stores an integer
set movie_length to "2 hours" -- stores a string
display dialog movie_length -- most of the time, AS will convert numbers to string for dd messages
display dialog (movie_length as string) -- but sometimes you need to coerce the variable

If you're having problems, you do realize that a tell statement needs an "end tell", right?

so ...

Code:
tell application "QuickTime Player"
     set movie_length to 120
end tell

do this help?

mt
 
yes thank you that helped. I have another question, I am trying to shorten a video, and I am pretty much done.

Code:
tell application "QuickTime Player"
	select at 0 to new_time
	????????????
end tell

I am trying to trim the length of the video(inplace of the ???? above), but it is never working! I have tried:

Code:
trim front document
trim
trim document

But everytime I do that, it doesn't trim it properly, just nothing happens! I know the right portion of the timeline is selected because I have run the script with a delay after the 'select' line, and I can see that the right part is selected. Now my understanding is that 'trim' is supposed to 'trim' this part. What am I doing wrong??

ps- thank you I really appreciate your help :):)
 
You're not passing the correct arguments.

Open AppleScript Editor, go to File > Open Dictionary and select QuickTime Player. Then search for "trim" and you'll see what arguments that command takes.

edit: I merged your threads since they overlap.
 
Thanks for merging them

I searched like you said, and I found this:
Code:
trim v : Remove all content before and after the current selection
trim specifier : movie

I am very new to applescript so I really don't know how to interpret that. What is a specifier?
 
There are two arguments to trim: the start and end time in seconds, so the format is:
Code:
trim [I]movie[/I] from [I]seconds[/I] to [I]seconds[/I]

If you only have one movie open, use "document 1" to refer to it, then fill in what seconds you want to trim it to.
 
Ok I have tried to do what you said, but I get an error when I try to compile. Here is a screenshot:

picture4qc.png


Just to clear things up, here is version data about the 'script editor' that I am using:

picture3qf.png

And lastly, here is the whole script, copy and pasted in

Code:
with timeout of 86400 seconds
	
	display dialog "Before beginning batch processing, make sure QuickTime Player is set to the desired export settings, and all videos to be processed are in a folder named ‘Input’ on the desktop." with icon note
	
	tell application "Finder"
		set the startup_disk to the name of the startup disk
	end tell
	
	set amount_to_trim to 30
	set user to do shell script "whoami"
	set input_folder_name to "Input"
	set input_folder to startup_disk & ":Users:" & user & ":Desktop:" & input_folder_name & ":"
	set user_desktop to startup_disk & ":Users:" & user & ":Desktop:"
	set output_folder to startup_disk & ":Users:" & user & ":Desktop:Output:"
	set file_extension to "_export.mp4"
	
	try
		tell application "Finder"
			make new folder at user_desktop with properties {name:"Output"}
		end tell
	end try
	
	try
		set the_folder_list to list folder input_folder without invisibles
		repeat with x from 1 to count of the_folder_list
			set the_file to input_folder & item x of the_folder_list
			set output_file to output_folder & item x of the_folder_list & file_extension
			tell application "QuickTime Player"
				activate
				try
					close front window
				end try
				open the_file
				trim document 1 from 0 to ((duration of document 1) - amount_to_trim)
				export front document to output_file as MPEG4 using most recent settings with replacing
				close front document
			end tell
		end repeat
	on error
		display dialog "This script requires a folder named ‘" & input_folder_name & "‘ located on the desktop." with icon stop
	end try
	
	beep
	
end timeout

Do you see what I am doing wrong? :confused:
 
Looks like there's a difference between Leopard QuickTime Player and Snow Leopard QuickTime Player.

The "trim" line compiles fine on my system. The "export" line following needs some tweaking, however.

mt
 
Do you see what I am doing wrong? :confused:

I am having exactly the same problem using QTP 7 on Snow Leopard

Code:
tell application "QuickTime Player 7"
	
	activate
	
	close every window
	
	open "/latest.mp3"
	
	set end_time to the duration of document 1
	
	tell document 1
		
		trim document from 1 to end_time
		
		export to "/latest.wav" as wave using settings preset "8 kHz 16 bit Mono"
		
	end tell
	
	quit
	
end tell

Did you ever find a solution or does anybody else know the answer?

thanks, pugu
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.