Class: Paperclip::Waveform
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::Waveform
- Defined in:
- lib/paperclip_processors/waveform.rb
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ Waveform
constructor
A new instance of Waveform.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ Waveform
Returns a new instance of Waveform.
3 4 5 6 7 8 9 |
# File 'lib/paperclip_processors/waveform.rb', line 3 def initialize file, = {}, = nil super @basename = File.basename(file.path) @waveform_opts = [:convert_options] @waveform_opts[:force] = true end |
Instance Method Details
#make ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/paperclip_processors/waveform.rb', line 11 def make wav = Tempfile.new [ @basename, '.wav'] wav.binmode begin Paperclip.run("ffmpeg", "-y -i :source -f wav :dest", :source => "#{File.(file.path)}", :dest => File.(wav.path)) rescue Cocaine::ExitStatusError => e raise Paperclip::Error, "error while processing wav for #{@basename}: #{e}" end png = Tempfile.new [ @basename, 'png' ] ::Waveform.generate wav, png, @waveform_opts png end |