使用apple脚本无法快速将mov导出到pngs

时间:2010-11-04 13:32:11

标签: applescript quicktime

我想知道是否有人可以告诉我如何使这个脚本工作。我试了几个小时,我无法弄清楚它失败的原因。

此脚本告诉Quicktime在快速电影/演示文稿(由主题演示文稿生成)中前进,并为此电影中每一章的每个最后一帧导出图像。

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格式保存图像。 脚本的相关部分在这里:

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

我尝试使用PNG和Photo-JPEG但它仍然只生成PICT格式的图像

有谁知道怎么做?我在剧本中找不到任何错误......它应该有用。

欢迎任何建议! Thx提前。

致以最诚挚的问候,

zhengtonic

更新

如果有人有兴趣我找到原因:

Quicktime 7无法从mov中抓取静止图像并将其导出为png / jpeg。 通过将视频转换为mp4而不是提取某些帧,我找到了一种解决方法。

1 个答案:

答案 0 :(得分:3)

比将电影重新编码为mp4更简单。在quicktime中,您可以从电影中导出图像序列。图像序列的图像可以是png图像。因此,您可以使用此方法。以下是您需要做的基本概要。它可能看起来很复杂,但它非常简单。

首先,创建导出为图像序列的设置文件。您可以通过启动导出并设置其设置来实现。然后运行此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