我正在爲我的視頻處理使用gem'paperclip-av-transcoder','0.6.2'。軌道和回形針中的異步視頻處理
我只需要編寫代碼讓我的視頻轉換成多種格式:
has_attached_file :video, :styles => {
:mp4 => { :format => 'mp4', :convert_options => { :output => { :vcodec => 'libx264', :acodec => 'copy' } } },
:ogg => { :format => 'ogg', :auto_rotate => true },
:webm => { :format => 'webm', :auto_rotate => true },
:flv => { :format => 'flv', :convert_options => { :output => { :ar => 44100 } }, :auto_rotate => true },
:thumb => { :geometry => "300x300#", :format => 'jpg', :time => 1, :auto_rotate => true }
}, :processors => [:transcoder]
但是這個代碼是同步的,在轉換期間被卡住的是上傳視頻的用戶。
我想補充一個異步包裝(工人)圍繞:轉碼器,所以我可以致電:
has_attached_file :video, :styles => {... }, :processors => [:wrapper_transcoder_worker]
我已經安裝了resque和Redis的一切工作。
對於如何在代碼轉換器中編寫異步工作程序,您有什麼想法嗎?
感謝您發佈解決方案。你能解釋爲什麼這能解決問題嗎? – paulmelnikow 2015-02-07 23:49:44
這個答案實際上可以解決很多情況 – Ben 2015-02-08 03:22:39