2015-11-27 82 views
0

我正在處理一個腳本來幫助我的工作流程。我的工作涉及音效設計,而且我經常需要拍攝視頻並提取音頻。無論源碼/壓縮如何,我都喜歡它.wav格式 - 質量最好,所有音頻編輯軟件均可接受,並且在實時環境中播放的費用最低。applescript-quicktime 7音頻(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 

回答

0

文件輸出應該有」 .WAV」擴展名。要做到這一點,我改了一下你的腳本,我刪除了‘告訴文檔中OUTFILE保存’。 如果你真的要刪除您最初的文件在導出後,你需要在腳本結尾添加(我更喜歡在刪除之前檢查導出是否成功!) 另外,你必須改變第一行以將選擇文件(用於我的測試)替換爲讀取來自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 
+0

哇,非常感謝你。我將在幾天內再次處理這個問題,但我想讓當然,我表示感謝你的時間。我會報告回來!乾杯。 – talkingtobrian