2013-01-12 52 views
0

我有一個applescript用於從視頻創建圖像序列。它適用於用尼康相機拍攝的電影。它爲我的佳能相機拍攝的電影創建了一串穩定的綠色圖像。奇怪的是,如果我使用quicktime手動導出圖像序列,它工作正常(沒有綠色圖像)。只有在通過腳本運行時,quicktime纔會創建綠色框架(順便說一句,所有綠色框架)。蘋果腳本quicktime圖像序列導出創建綠色幀

下面是代碼:

#set vFile to (choose file with prompt "Select a video file:") 
on open of finderObjects -- "open" handler triggered by drag'n'drop launches 
    repeat with vFile in (finderObjects) -- in case multiple objects dropped on applet 
     tell application "Finder" 
      list folder ":Library:QuickTime:Presets" 
      set theList to result 
      set qSet to (choose from list theList) 
      set vBase to the name of vFile 
     end tell 

     tell application "Finder" 
      if (folder ((path to movies folder as string) & "TLTemp") exists) then 
       delete folder ((path to movies folder as string) & "TLTemp") 
      end if 

      if not (folder ((path to movies folder as string) & "TLTemp") exists) then 
       set TLDir to make new folder at (path to movies folder as string) with properties ¬ 
        {name:"TLTemp"} 
      end if 
     end tell 


     #tell application "QuickTime Player 7" to open vFile 
     tell application "QuickTime Player 7" 
      open vFile 
      set settings_file to (":Library:QuickTime:Presets:" & qSet) 
      set TLtemp to ((path to movies folder as string) & "TLTemp:" & vBase) 
      with timeout of 500 seconds 
       export document 1 to TLtemp as image sequence using settings settings_file 
      end timeout 
      #export document 1 to TLtemp as image sequence 

      close document 1 
     end tell 

     set the item_list to list folder ((path to movies folder as string) & "TLTemp:") without invisibles 
     set pictureFile to ((path to movies folder as string) & "TLTemp:" & item 1 of item_list) 
     tell application "QuickTime Player 7" 
      activate 
      open image sequence pictureFile frames per second 30 
      set the looping of document 1 to true 
      play document 1 
     end tell 



    end repeat 
end open 

回答

0

我從來沒有與圖像序列的工作,但我有打開Finder的選擇項中的QuickTime 7並捕獲10靜止影像PICT文件一個AppleScript。如果您將前端文檔的當前時間增加一幀(而不是像我一樣持續時間/ 11),它可以幫助您嗎?

-- Use iPhoto to convert these PICT files to PNGs. 
set exportFolder to (path to the desktop as text) & "photos from QuickTime:" 
set picturesPerVideo to 10 



tell application "Finder" to set theSelection to the selection as list 
repeat with i from 1 to (count of theSelection) 
    set theItem to item i of theSelection 
    tell application "Finder" 
     set finderPath to (file (theItem as text))'s POSIX path 
     set theName to theItem's name 
     open theItem using (path to application "QuickTime Player 7") 
    end tell 
    set theCurrentDate to current date 
    tell application "System Events" to set process "QuickTime Player 7"'s visible to false 
    tell application "QuickTime Player 7" 
     repeat until front document's path = finderPath 
      if ((current date) - 15) > theCurrentDate then error "Timeout." 
      delay 1 
     end repeat 

     repeat with j from 1 to picturesPerVideo 
      set timeInVideo to j/(picturesPerVideo + 1) 
      set front document's current time to (front document's duration) * timeInVideo 
      set exportPath to exportFolder & theName & "_" & j & ".pict" 
      export front document to exportPath as picture replacing yes 
     end repeat 
     close front document 
    end tell 
end repeat 

對於遲到的答案抱歉。我剛剛遇到你的帖子。

+0

這並不能解決我的問題,因爲問題發生在快速導出過程中。 iPhoto無法從視頻文件中導出幀。 – tavis

+0

我使用QuickTime 7生成.PICT圖像,然後僅使用iPhoto將它們轉換爲不同的圖像格式。你是說上面的AppleScript爲你生成穩定的綠色圖像嗎?你能給我一段你的片段供我測試嗎? [該腳本適用於我。](http://dl.dropbox.com/u/475192/2013_03_22.mov) –

+0

該腳本適用於使用尼康相機拍攝的視頻。但用我的canon powershot,我可以在進行圖像序列輸出時獲得所有可靠的綠色圖像。 – tavis