1

I've searched around on google and have come up with only one site that explains how to do this: http://railsonedge.blogspot.com/2009/01/flash-video-tutorial-with-rails-ffmpeg.html?m=0 I'm already using paperclip and already have everything set up with it and like using it better than the way this site is doing it. Is there a way to convert videos in the background while keeping track of the state of it using paperclip? My Video.rb currently:

class Video < ActiveRecord::Base
  belongs_to :user
  has_many :comments, dependent: :destroy
  attr_accessible :video, :user_id, :video_file_name, :title, :public, :description, :views

  has_attached_file :video, :styles => { 
    :video => { geometry: "800x480>", format: 'webm' },
    :thumb => { geometry: "200x200>", format: 'png', time: 3 },
  }, processors: [:ffmpeg], url: "/users/:user_id/videos/:id/:basename_:style.:extension"

  #process_in_background :video #causes death

  validates :video, presence: true
  validates :description, presence: true, length: { minimum: 5, maximum: 100}
  validates :title, presence: true, length: { minimum: 1, maximum: 15 }

  validates_attachment_size :video, less_than: 1.gigabytes
  validates_attachment :video, presence: true

  default_scope order: 'created_at DESC'

  Paperclip.interpolates :user_id do |attachment, style|attachment.instance.user_id
  end

  def self.search(search)
    if search
      find(:all, conditions: ["public = 't' AND title LIKE ?", "%#{search}%"], order: "created_at DESC")
    else
      find(:all, conditions: ["public = 't'"], order: "created_at DESC")
    end
  end

  def self.admin_search(search)
    if search
      find(:all, conditions: ['title LIKE ?', "%#{search}%"], order: "created_at DESC")
    else
      find(:all, order: "created_at DESC")
    end
  end

end
4

1 回答 1

0

首先检查这个答案。对于您要使用的后台作业sidekiq。您将需要处理转换的方法。您将在 sidekiq 的#perform 中调用该方法。在此方法中,您还可以更改状态(只需更改字符串字段值)。

于 2012-10-02T07:54:35.087 回答