Applescript can';t获取quicktime以使用apple脚本将mov导出到PNG

Applescript can';t获取quicktime以使用apple脚本将mov导出到PNG,applescript,quicktime,Applescript,Quicktime,我想知道是否有人能告诉我如何使这个脚本工作。我试了几个小时,但我不明白为什么失败了 此脚本告诉Quicktime在Quicktime电影/演示文稿(由keynote生成)中前进,并为此电影中每个章节的最后一帧导出图像 property Main_folder : missing value set Main_folder to choose folder tell application "QuickTime Player 7" if not (exists document 1) t

我想知道是否有人能告诉我如何使这个脚本工作。我试了几个小时,但我不明白为什么失败了

此脚本告诉Quicktime在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格式保存图像。 脚本的相关部分如下所示:

export to (T_target & T_name & " Chapter " & i) as picture using settings preset "Photo-JPEG" -- or "Uncommpressed", or "PNG"
我尝试了PNG和照片JPEG,但它仍然只能生成PICT格式的图像

有人知道怎么做吗?我在剧本中找不到任何错误。。。它应该会起作用

欢迎任何意见!Thx提前

致以最良好的祝愿

正统

更新

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

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

有一个比将电影重新编码为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

有一种比将电影重新编码为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