如何让 AppleScript 使用正确版本的 QuickTime Player 打开电影?

发布于 2024-12-10 07:27:10 字数 1350 浏览 0 评论 0原文

我尝试在 QuickTime Player 7 v7.6.6 中使用以下脚本将 AVI 容器文件批量转换为 MOV 容器文件:

tell application "Finder"

    try
        set myFolder to (the folder of the front window) as alias
    on error
        beep
    end try

    -- get list of .avi files
    set aviFiles to files of myFolder whose name contains ".avi"
end tell

tell application "QuickTime Player 7" to activate

repeat with aviFile in aviFiles
    set aviName to name of aviFile as text
    set dispName to (text 1 thru ((length of aviName) - 4)) of aviName
    set movName to dispName & ".mov"
    set movPath to (POSIX path of myFolder & movName)

    tell application "QuickTime Player 7"
        open aviFile
        save front document in movPath
        close front document
    end tell

end repeat

当我在 Finder 中选择一个文件夹并运行此脚本时,出现以下错误:

QuickTime Player 7 出现错误:无法获取文档 1。索引无效。

当我运行脚本时,QuickTime Player X 和 QuickTime Player 7 都被激活(打开)。

看起来电影文件 aviFile 实际上是在 QuickTime Player X 中打开的,而不是 QuickTime Player 7,这可以解释为什么错误消息指出 QTP7 无法获取文档 1。

有没有办法修复这个脚本,以便它在 QuickTime Player 7 而不是 QuickTime Player X 中打开 AVI 电影?有没有办法通过命令行控制 QuickTime Player 7?

请注意,我不想使用像 ffmpegX (或类似的)这样的转码器,这会降低 AVI 的质量(并且还会增大文件大小)。我只想使用新的 MOV 容器自动重新保存 AVI,以便 iTunes 可以使用我已经安装的编解码器来播放它。谢谢你的建议。

I am attempting to use the following script with QuickTime Player 7 v7.6.6 to batch-convert AVI-container files to MOV-container files:

tell application "Finder"

    try
        set myFolder to (the folder of the front window) as alias
    on error
        beep
    end try

    -- get list of .avi files
    set aviFiles to files of myFolder whose name contains ".avi"
end tell

tell application "QuickTime Player 7" to activate

repeat with aviFile in aviFiles
    set aviName to name of aviFile as text
    set dispName to (text 1 thru ((length of aviName) - 4)) of aviName
    set movName to dispName & ".mov"
    set movPath to (POSIX path of myFolder & movName)

    tell application "QuickTime Player 7"
        open aviFile
        save front document in movPath
        close front document
    end tell

end repeat

When I select a folder in the Finder and run this script, I get the following error:

QuickTime Player 7 got an error: Can’t get document 1. Invalid index.

Both QuickTime Player X and QuickTime Player 7 are activated (opened) when I run the script.

It looks like the movie file aviFile actually opens up in QuickTime Player X, not QuickTime Player 7, which would explain why the error message notes that QTP7 can't get document 1.

Is there a way to fix this script, so that it opens up the AVI movie in QuickTime Player 7 and not QuickTime Player X? Is there a way to control QuickTime Player 7 via the command line?

Note that I do not want to use a transcoder like ffmpegX (or similar), which reduces the quality of the AVI (and also blows up the file size). I just want to automate resaving the AVI with a new MOV container, so that iTunes can play it with codecs I have already installed. Thanks for your advice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无名指的心愿 2024-12-17 07:27:10

这里不是“回答错误的问题”,而是 ffmpeg 可以在不转码的情况下转换容器(因此不会显着改变文件大小或降低质量):

ffmpeg -vcodec copy -acodec copy -i inputFile.avi outputFile.mov

Not to "answer the wrong question" here, but ffmpeg can convert containers without transcoding (and hence without changing the file size significantly or decreasing the quality):

ffmpeg -vcodec copy -acodec copy -i inputFile.avi outputFile.mov
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文