使用sidekiq rails对视频进行后台处理

时间:2014-04-23 09:22:34

标签: ruby-on-rails video

如何配置sidekiq用于视频的后台处理以及从临时位置显示视频,直到视频在后台处理为止。建议我一些想法。

video.rb

class Video < ActiveRecord::Base
  attr_accessible :video, :event_id,:user_id
  belongs_to :event 
  has_many :favorite_videos, dependent: :destroy
  acts_as_readable :on => :updated_at

  validates_presence_of :video, :school_id, :user_id
  validates_attachment :video, presence: true

  has_attached_file :video, 
                path: ":folder_name/:class/:id/:style/:basename.:extension",
                storage: :s3, 
                s3_host_name: PAPERCLIP_S3[:host_name], 
                bucket: PAPERCLIP_S3[:bucket], 
                s3_credentials: PAPERCLIP_S3[:credentials],                    
                :s3_permissions => :private,
                :styles => {
                  :flv => { :geometry => "1024x576", :format => 'flv', :convert_options => {:output => {:ar => 44100}} },
                  :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 3 }
                }, :processors => [:ffmpeg]


  validates_attachment :video, content_type: {content_type: ['application/x-shockwave-flash', 'application/x-shockwave-flash', 'application/flv', 'video/x-flv', 'video/mp4', 'application/x-mp4', 'application/mp4', 'video/x-mp4','video/quicktime']}

  def video_url(style = 'original')
    begin
      video.expiring_url(108000, style)
    rescue Exception => e
      ""
    end  
  end   
end

由于

0 个答案:

没有答案