Class: Paperclip::AudioCrop
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::AudioCrop
- Defined in:
- lib/paperclip_processors/audio_crop.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#offset ⇒ Object
Returns the value of attribute offset.
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ AudioCrop
constructor
A new instance of AudioCrop.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ AudioCrop
Returns a new instance of AudioCrop.
5 6 7 8 9 10 11 |
# File 'lib/paperclip_processors/audio_crop.rb', line 5 def initialize file, = {}, = nil super @offset = [:offset] @duration = [:duration] @current_format = File.extname(@file.path) @basename = File.basename(file.path) end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
3 4 5 |
# File 'lib/paperclip_processors/audio_crop.rb', line 3 def duration @duration end |
#offset ⇒ Object
Returns the value of attribute offset.
3 4 5 |
# File 'lib/paperclip_processors/audio_crop.rb', line 3 def offset @offset end |
Instance Method Details
#make ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/paperclip_processors/audio_crop.rb', line 13 def make src = @file dst = Tempfile.new([@basename, @current_format]) dst.binmode begin success = Paperclip.run("ffmpeg -y -ss #{@offset} -t #{@duration} -i #{src.path} -acodec copy #{dst.path}") rescue PaperclipCommandLineError => e raise Paperclip::Error, "error while processing audio for #{@file}: #{e}" end dst end |