Quicktime 7 cut

Hello I’m new to Applescript:D

I’m trying to create a drag&drop application that cut a portion of a movie (from start to x)

on open file
tell application “QuickTime Player 7”
activate
open currentFile
set i to 0
set o to 10000
select at i to o
cut document 1
end tell
end open

it dosen’t cut anything… (without the cut line the selection is correctly made) HELP

Also is it possible to use the frame class to use frames to set i and o variables?

I’m using QT Pro 7.6.6 and Mac OS X 10.6.8

Hi,

the parameter of on open is a list of files
so a repeat loop is needed to process one file after another.
the select command needs also the document reference as the direct parameter
Try this, the script works as applet too and checks the kind of the file

Probably you still have to add code to save and close the file


on run
	open (choose file with multiple selections allowed)
end run

on open theFiles
	tell application "QuickTime Player 7"
		stop every document
		activate
	end tell
	repeat with aFile in theFiles
		try
			tell application "System Events"
				set quickTimeFile to QuickTime file (aFile as text)
				set fileIsMovie to kind of quickTimeFile contains "movie"
			end tell
			if fileIsMovie then
				tell application "QuickTime Player 7"
					open aFile
					set input to 0
					set output to 10000
					tell document 1
						select it at input to output
						cut
					end tell
				end tell
			end if
		end try
	end repeat
end open

great!

I’ve tried your script but QT dosn’t actually cut the portion selected :confused:

I have tried to use trim instead of cut the selection is really trimmed (but in this manner I have to make selection beetween 10000 and the end of the video, don’t know how to do that…)

Can’t find the delete action (edit menu in QT) in the QT dictionary

thanks for the help

Actually it does cut the selection, but as mentioned the file is not saved automatically.

Ok tried with other files and it worked

The files that dosen’t cut are mp4 that when using the QT Save as (to save in .mov) return the error message: Movie contains an incorrect time value

two ways I have found to “correct” those files are:

  • delete the first say 10 frames and than save
  • use Atom Inspector to set the first line of ctts to 0…

Maybe this is why the cut dosn’t work (or better it dosn’t work with the first frames selected, with any central selection it does)

As I’ve said the trim command worked so, how can I make a selection from point x to the end of file?


.
set input to 10000
					tell document 1
						set output to duration
						select it at input to output
						trim
					end tell
.

Well this worked wonderfully!
How can I add lines to Save As .mov (without any changes in size, fps, ecc…) and to Close window?

es of app:

  • Choose file to edit (or drag&drop)
  • Choose destination dir (same selectable directory for all files)
  • Editing process, save (using original name) and close
  • Repeat last step for every file

try this


on run
	open (choose file with multiple selections allowed)
end run

on open theFiles
	set destinationFolder to choose folder
	tell application "QuickTime Player 7"
		stop every document
		activate
	end tell
	repeat with aFile in theFiles
		try
			tell application "System Events"
				set quickTimeFile to QuickTime file (aFile as text)
				set fileIsMovie to kind of quickTimeFile contains "movie"
				set {name:fileName, name extension:fileExtension} to quickTimeFile
				set baseName to text 1 thru ((get offset of "." & fileExtension in fileName) - 1) of fileName
			end tell
			if fileIsMovie then
				tell application "QuickTime Player 7"
					open aFile
					set input to 100000
					tell document 1
						set output to duration
						select at input to output
						trim
						save self contained in file ((destinationFolder as text) & baseName & ".mov")
						close
					end tell
				end tell
			end if
		end try
	end repeat
end open


you’re great!

One last thing: what if I have to export to mpeg4 (in the selected folder) with current setting?

I’ve tried with

export aFile to ((destinationFolder as text) & baseName & “.mp4”) as MPEG4 with current settings

in place of

save self contained in file ((destinationFolder as text) & baseName & “.mov”)

but it dosn’t work, can you explain why?

if you don’t want to change the file format, just write

save

instead of the save self contained line

or

close saving yes

instead of the save and close line

export aFile does not work because there is already a reference to the document (the tell block)
and aFile is an alias specifier not a QuickTime document