首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法用苹果脚本将mov导出到pngs

无法用苹果脚本将mov导出到pngs
EN

Stack Overflow用户
提问于 2010-11-04 13:32:10
回答 1查看 1.6K关注 0票数 0

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

此脚本告诉Quicktime在快速电影/演示(由基调生成)中前进,并导出该电影中每一章的每一帧的图像。

代码语言:javascript
运行
复制
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格式。剧本的相关部分如下:

代码语言:javascript
运行
复制
export to (T_target & T_name & " Chapter " & i) as picture using settings preset "Photo-JPEG" -- or "Uncommpressed", or "PNG"

我尝试了PNG和和Photo-JPEG,但是它仍然只生成PICT格式的图像。

有人知道怎么做吗?我在剧本里找不到任何错误..。应该管用的。

欢迎任何建议!提前结束。

诚挚的问候,

正丁香

更新

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-11-04 20:51:58

还有一种比把电影重新编码成mp4更简单的方法。在快速时间内,您可以从电影中导出图像序列。图像序列的图像可以是png图像。因此,您可以使用applescript。这是你需要做的事情的基本轮廓。这看起来可能很复杂,但真的很简单。

首先,为导出作为图像序列创建一个设置文件。您可以通过启动导出并为此设置设置来做到这一点。然后运行此applescript将设置保存在文件中.

代码语言:javascript
运行
复制
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需要一段时间才能得到图像,然后您基本上可以修剪电影,使其只包含当时的帧,然后使用设置文件作为图像导出该帧,如下所示.注意:我没有测试以下脚本

代码语言:javascript
运行
复制
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
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4097142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档