2010-11-04 76 views
0

我在想如果有人能告訴我如何讓這個腳本工作。我嘗試了幾個小時,我無法弄清楚它爲什麼失敗。無法使用蘋果腳本將mov導出到png中

此腳本告訴Quicktime在快速時間電影/演示(由keynote生成)中前進,併爲該電影中每個章節的每個最後一幀導出圖像。

property Main_folder : missing value 
set Main_folder to choose folder 

tell application "QuickTime Player 7" 
    if not (exists document 1) then error "No movies are open." 
    stop movies 
    tell front document to set {currMovie, T_name, duration_list, current time} to ¬ 
     {it, text 1 thru -5 of (get name), duration of chapters of (get first track whose kind is "Sprite"), 0} 
    set T_target to my makeFolder(T_name) 

    repeat with i from 1 to (count duration_list) 
     tell currMovie 
      set current time to current time + (item i of duration_list) 
      export to (T_target & T_name & " Chapter " & i) as picture using settings preset "Photo-JPEG" -- or "Uncommpressed", or "PNG" 
     end tell 
    end repeat 
end tell 

on makeFolder(n) 
    tell application "Finder" to return (make new folder at Main_folder with properties 

這裏我的問題是,它保存PICT格式而不是PNG圖像。 腳本的relevat一部分是在這裏:

export to (T_target & T_name & " Chapter " & i) as picture using settings preset "Photo-JPEG" -- or "Uncommpressed", or "PNG" 

我嘗試了用PNG和只有照片的JPEG,但它仍然只是在PICT格式生成圖像

有誰知道如何做到這一點?我在腳本中找不到任何錯誤......它應該可以工作。

歡迎任何建議! Thx提前。

最好的問候,

zhengtonic

更新

如果有人有興趣,我發現了原因:

的QuickTime 7不能夠從一個MOV虎視眈眈的靜止圖像和將其導出爲png/jpeg。 我通過將視頻轉換爲mp4並提取某些幀找到了解決方法。

回答

3

還有一種比將電影重新編碼爲mp4更簡單的方法。在quicktime中,您可以從電影中導出圖像序列。圖像序列的圖像可以是png圖像。因此,你可以appmarkscript這個。以下是你需要做的基本概述。它看起來很複雜,但它非常簡單。

首先,爲輸出創建一個設置文件作爲圖像序列。您可以通過開始導出併爲其設置設置。然後運行該AppleScript的保存設置在文件...

set exportFileName to "ImageSequenceExportSettings.qtSettings" 
set exportFilePath to (path to desktop as text) & exportFileName 

tell application "QuickTime Player 7" 
    tell first document 
     save export settings for image sequence to file exportFilePath 
    end tell 
end tell 

其次,你的AppleScript需要在您想要的圖像時,那麼你基本上剪掉短片,使其僅包含該時間框架,那麼你使用設置文件導出該幀作爲你的圖像,像這樣...注意:我沒有測試下面的腳本

set timeOfImage to 60 -- in seconds 
set settingsFile to (path to desktop as text) & "ImageSequenceExportSettings.qtSettings" 

tell application "QuickTime Player 7" 
    tell document 1 
     if (can export as image sequence) then 
      -- trim the movie to one frame 
      set ts to time scale 
      set theFrame to timeOfImage * ts 
      select at theFrame to (theFrame + 1) 
      trim 

      -- save the image 
      set theName to text 1 thru -5 of (get name) 
      set outPath to (path to desktop as text) & theName & ".png" 
      export to outPath as image sequence using settings settingsFile 

      -- close the movie 
      close saving no 
     else 
      error "The front movie cannot be exported to an image sequence!" 
     end if 
    end tell 
end tell 
+0

我發現了另一個解決方案,但thx隊友! – zhengtonic 2010-12-17 19:50:45