class Paperclip::FfmpegWavToMp3
Attributes
file[RW]
format[RW]
params[RW]
Public Class Methods
new(file, options = {}, attachment = nil)
click to toggle source
Calls superclass method
# File lib/paperclip_processors/ffmpeg_wav_to_mp3.rb, line 7 def initialize(file, options = {}, attachment = nil) super @file = file @params = options[:params] || '-y -i' @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) @format = options[:format] || 'mp3' end
Public Instance Methods
make()
click to toggle source
# File lib/paperclip_processors/ffmpeg_wav_to_mp3.rb, line 16 def make source = @file output = Tempfile.new([@basename, @format ? ".#{@format}" : '' ]) begin parameters = [@params, ':source', ':dest'].flatten.compact.join(' ').strip.squeeze(' ') Paperclip.run('ffmpeg', parameters, :source => File.expand_path(source.path), :dest => File.expand_path(output.path)) rescue PaperclipCommandLineError raise PaperclipError, "There was an error converting #{@basename} to mp3" end output end