module Paperclip class VideoConvert < Processor attr_accessor :whiny, :tt, :file, :basename def initialize(file, options = {}, attachment = nil) super @file = file @whiny = options[:whiny].nil? ? true : options[:whiny] @basename = File.basename(file.path, File.extname(file.path)) @data = attachment end def make src = @file flv = Tempfile.new([ @basename, 'flv' ].compact.join(".")) flv.close command = <<-end_command -i #{File.expand_path(src.path)} -ar 22050 -ab 32 -acodec libmp3lame -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y #{File.expand_path(flv.path)} end_command command.gsub!(/\s+/, " ") @tt = command begin success = Paperclip.run('ffmpeg', command) rescue PaperclipCommandLineError raise PaperclipError, "There was an error processing the video convert for #{@basename}" if whiny end flv end end end