2010-11-04 77 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