Search code examples
ruby-on-railspaperclipresque

Async video processing in rails and paperclip


I'm using gem 'paperclip-av-transcoder', "0.6.2" for my video processing.

I simply need to write this code to have my video converted into many formats:

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]

But this code is synchronous and the user that upload the video is stuck during the conversion.

I would like to add an async wrapper (worker) around :transcoder so I can call:

has_attached_file :video, :styles => {... }, :processors => [:wrapper_transcoder_worker]

I have installed resque and redis and everything work.

Do you have an idea on how can I write the asynch worker around transcoder?


Solution

  • lock paperclip at version 4.2.0