开发者

function not working in production mode

I am using the rvideo gem to transcode files to a .flv format.

  class Video < ActiveRecord::Base
  include AASM
  aasm_column :status
  aasm_initial_state :initial

  aasm_state :initial
  aasm_state :converting, :exit => :transcode
  aasm_state :transfering , :exit => :send_s3
   aasm_state :completed
   aasm_state :failed

  aasm_event :convert do
   transitions :from => [:initial], :to => :converting
    end

   aasm_event :transfer do
   transitions :from => [:converting], :to => :transfering
    end

   aasm_event :complete do
    transitions :from => [:transfering], :to => :completed
   end

    aasm_event :error do
     transitions :from =&开发者_运维知识库gt; [:initial, :converting, :transfering, :completed]
     end

   has_attached_file :asset, 
     :path => "uploads/:attachment/:id.:basename.:extension"

     def flash_path
    return self.asset.path + '.flv'
    end

    def flash_name
      return File::basename(self.asset.path)# + '.flv'
     end

    def flash_url
    return "#{AWS_HOST}/#{AWS_BUCKET}/#{self.flash_name}"
   end

  # transcode file
   def transcode
     begin
    RVideo::Transcoder.logger = logger
     file = RVideo::Inspector.new(:file => self.asset.path)
  command = "ffmpeg -i $input_file$ -y -s $resolution$ -ar 44100 -b 64k -r 15 -sameq  $output_file$"
    options = {
    :input_file => "#{RAILS_ROOT}/#{self.asset.path}",
    :output_file => "#{RAILS_ROOT}/#{self.flash_path}",
    :resolution => "320x200" 
  }


  transcoder = RVideo::Transcoder.new
  transcoder.execute(command, options)
  rescue RVideo::TranscoderError => e
    logger.error "Encountered error transcoding #{self.asset.path}"
    logger.error e.message
  end
 end

The input file is added to the asset directory, but I never get an outputted file. On the view page aasm hangs on "converting".


This might sound ridiculous, but what do your server logs say when it hangs? It's likely a server problem. In fact, it seems that rvideo needs alot of ram, so if you are running this on a shared host, or some slice that has only 256 ram or something you may need alot more.

Try running it in production mode on your development machine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜