How do I get AppleScript to open a movie with the right version of QuickTime Player?
I am attempting to use the following script with QuickTime Player 7 v7.6.6 to batch-convert AVI-container files to MOV-container files:
tell application "Finder"
try
set myFolder to (the folder of the front window) as alias
on error
beep
end try
-- get list of .avi files
set aviFiles to files of myFolder whose name contains ".avi"
end tell
tell application "QuickTime Player 7" to activate
repeat with aviFile in aviFiles
set aviName to name of aviFile as text
set dispName to (text 1 thru ((length of aviName) - 4)) of aviName
set movName to dispName & ".mov"
set movPath to (POSIX path of myFolder & movName)
开发者_开发百科 tell application "QuickTime Player 7"
open aviFile
save front document in movPath
close front document
end tell
end repeat
When I select a folder in the Finder and run this script, I get the following error:
QuickTime Player 7 got an error: Can’t get document 1. Invalid index.
Both QuickTime Player X and QuickTime Player 7 are activated (opened) when I run the script.
It looks like the movie file aviFile
actually opens up in QuickTime Player X, not QuickTime Player 7, which would explain why the error message notes that QTP7 can't get document 1.
Is there a way to fix this script, so that it opens up the AVI movie in QuickTime Player 7 and not QuickTime Player X? Is there a way to control QuickTime Player 7 via the command line?
Note that I do not want to use a transcoder like ffmpegX (or similar), which reduces the quality of the AVI (and also blows up the file size). I just want to automate resaving the AVI with a new MOV container, so that iTunes can play it with codecs I have already installed. Thanks for your advice.
Not to "answer the wrong question" here, but ffmpeg can convert containers without transcoding (and hence without changing the file size significantly or decreasing the quality):
ffmpeg -vcodec copy -acodec copy -i inputFile.avi outputFile.mov
精彩评论