【问题标题】:applescript - quicktime 7 audio (wav) exportapplescript - quicktime 7 音频 (wav) 导出
【发布时间】:2015-11-27 16:19:23
【问题描述】:

我正在编写一个脚本来帮助我的工作流程。我的工作涉及声音设计,我经常需要拍摄视频并提取音频。无论源/压缩如何,我都喜欢 .wav 格式 - 最好的质量,被所有音频编辑软件接受,并且在现场环境中播放的开销最小。

目前,我为此任务使用 Quicktime Pro 7 的导出功能 - 当前的 Quicktime X 不导出为 .wav。内置在操作系统中,所以我没有使用单独的工具,而是使用 QT。

我正在使用 Automator 编写服务 - 选择文件,在 QT 中打开它,导出为 wav 并将其保存在与原始文件相同的位置,然后退出。这是我到目前为止所拥有的,并且我不断收到错误消息。 ““运行 AppleScript”操作遇到错误。”它编译正确,但没有任何结果。昨晚深夜,出于某种原因,我让它吐出 .mov 文件(尽管试图告诉它挥手),现在我什至无法回到那里。

感谢任何帮助。正如您从评论部分看到的那样,我试图指定任何地方,因为试图使其与原件相同的位置正在逃避我。目前我只是让它提示我在哪里保存,所以我一次只能解决一个问题。干杯!

tell application "QuickTime Player 7"
--set saveFile to POSIX path of (((path to desktop) as Wave) & "test.wav")
set outfile to choose file name with prompt "Save altered file here:"
set error_states to {load state unknown, load error}
set successful_states to {loaded, complete}
repeat until load state of first document is in (error_states & successful_states)
    delay 0.1
end repeat
tell document to save in outfile

if (load state of first document is in successful_states) then
    if (can export first document as wave) then
        export first document to outfile as wave
    else
        error "Cannot export " & (source_file as string) & " in .wav (Wave) format."
    end if
else
    error "File is not in a successful load state: " & (load state of first document as string)
end if
end tell

【问题讨论】:

    标签: qt audio applescript


    【解决方案1】:

    文件输出应该有“.wav”扩展名。为此,我更改了一些脚本并删除了“告诉文档保存在输出文件中”。 如果您真的想在导出后删除初始文件,则需要在脚本末尾添加该文件(我更喜欢在删除之前检查导出是否成功!)。 此外,您必须更改第一行以将选择文件(用于我的测试)替换为 Automator 服务脚本中的读取输入变量:

    set InFile to choose file "select video file for test only" -- to be replace by the input of your Automator Service
    
    -- conversion of selected file with proper folder and new '.wav" extension
    tell application "Finder"
    set FFolder to (container of InFile) as string
    set FName to name of InFile
    set FExt to name extension of InFile
    end tell
    set Pos to offset of FExt in FName
    if Pos > 0 then --change extension from current to 'wav'
    set OutFile to FFolder & (text 1 thru (Pos - 1) of FName) & "wav"
    else
    set OutFile to FFolder & FName & ".wav"
    end if
    
    tell application "QuickTime Player 7"
    activate
    open InFile
    set error_states to {load state unknown, load error}
    set successful_states to {loaded, complete}
    repeat until load state of first document is in (error_states & successful_states)
        delay 0.1
    end repeat
    if (load state of first document is in successful_states) then
        if (can export first document as wave) then
            export first document to OutFile as wave
        else
            error "Cannot export " & (source_file as string) & " in .wav (Wave) format."
        end if
    else
        error "File is not in a successful load state: " & (load state of first document as string)
    end if
    end tell
    

    【讨论】:

    • 哇,非常感谢。几天后我会再次处理这个问题,但我想确保我说谢谢你的时间。我会回来报告的!干杯。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-22
    相关资源
    最近更新 更多