Class: Paperclip::Poster
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::Poster
- Defined in:
- lib/paperclip_processors/poster.rb
Instance Attribute Summary collapse
-
#geometry ⇒ Object
Returns the value of attribute geometry.
-
#time_offset ⇒ Object
Returns the value of attribute time_offset.
-
#whiny ⇒ Object
Returns the value of attribute whiny.
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ Poster
constructor
A new instance of Poster.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ Poster
Returns a new instance of Poster.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/paperclip_processors/poster.rb', line 9 def initialize(file, = {}, = nil) super @time_offset = [:time_offset] || '-4' @instance = .instance @video = RVideo::Inspector.new(:file => file.path) @instance.width = @video.width @instance.height = @video.height @whiny = [:whiny].nil? ? true : [:whiny] @basename = File.basename(file.path, File.extname(file.path)) end |
Instance Attribute Details
#geometry ⇒ Object
Returns the value of attribute geometry.
7 8 9 |
# File 'lib/paperclip_processors/poster.rb', line 7 def geometry @geometry end |
#time_offset ⇒ Object
Returns the value of attribute time_offset.
7 8 9 |
# File 'lib/paperclip_processors/poster.rb', line 7 def time_offset @time_offset end |
#whiny ⇒ Object
Returns the value of attribute whiny.
7 8 9 |
# File 'lib/paperclip_processors/poster.rb', line 7 def whiny @whiny end |
Instance Method Details
#make ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/paperclip_processors/poster.rb', line 22 def make dst = Tempfile.new([ @basename, 'jpg' ].compact.join(".")) dst.binmode cmd = %Q[-itsoffset #{time_offset} -i "#{File.(file.path)}" -y -vcodec mjpeg -vframes 1 -an -f rawvideo ] cmd << "-s #{@video.resolution} " if @video && @video.resolution cmd << %Q["#{File.(dst.path)}"] begin success = Paperclip.run('ffmpeg', cmd) rescue PaperclipCommandLineError raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if whiny end dst end |