2011-10-17 156 views
0

我試圖使用使用QuickTime Player 7 v7.6.6下面的腳本AVI容器文件批量轉換爲MOV容器文件:如何讓AppleScript使用正確版本的QuickTime Player打開電影?

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 

當我選擇在Finder中的文件夾,然後運行該腳本,我收到以下錯誤:

QuickTime Player 7 got an error: Can’t get document 1. Invalid index.

當我運行腳本時,QuickTime Player X和QuickTime Player 7都被激活(打開)。

它看起來像電影文件aviFile實際上在QuickTime Player X,不是QuickTime播放器7,打開這可以解釋爲什麼該錯誤消息指出,QTP7不能得到文件1.

有沒有一種辦法修復此腳本,以便在QuickTime Player 7中打開AVI電影,而不是QuickTime Player X?有沒有辦法通過命令行來控制QuickTime Player 7?

請注意,我不想使用像ffmpegX(或類似的)這樣的代碼轉換器,它會降低AVI的質量(並且還會擴大文件大小)。我只想用一個新的MOV容器自動保存AVI,以便iTunes可以使用我已安裝的編解碼器播放它。謝謝你的建議。

回答

0

不要「回答錯誤的問題」在這裏,但ffmpeg的可以轉換成容器,無需轉碼(因此沒有顯著改變文件大小或者降低質量):

ffmpeg -vcodec copy -acodec copy -i inputFile.avi outputFile.mov 
相關問題