Class: Paperclip::Qtfaststart
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::Qtfaststart
- Defined in:
- lib/paperclip_processors/qtfaststart.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#streaming ⇒ Object
Returns the value of attribute streaming.
-
#whiny ⇒ Object
Returns the value of attribute whiny.
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ Qtfaststart
constructor
Creates a Video object set to work on the
filegiven. -
#make ⇒ Object
Performs the atom repositioning on
file.
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ Qtfaststart
Creates a Video object set to work on the file given. It will attempt to reposition the moov atom in the video given if streaming is set.
8 9 10 11 12 13 14 15 16 |
# File 'lib/paperclip_processors/qtfaststart.rb', line 8 def initialize file, = {}, = nil @streaming = [:streaming] @file = file @whiny = [:whiny].nil? ? true : [:whiny] @format = [:format] @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) .instance_write(:meta, @meta) end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
3 4 5 |
# File 'lib/paperclip_processors/qtfaststart.rb', line 3 def format @format end |
#streaming ⇒ Object
Returns the value of attribute streaming.
3 4 5 |
# File 'lib/paperclip_processors/qtfaststart.rb', line 3 def streaming @streaming end |
#whiny ⇒ Object
Returns the value of attribute whiny.
3 4 5 |
# File 'lib/paperclip_processors/qtfaststart.rb', line 3 def whiny @whiny end |
Instance Method Details
#make ⇒ Object
Performs the atom repositioning on file. Returns the Tempfile that contains the new video or the original file if streaming wasn’t set.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/paperclip_processors/qtfaststart.rb', line 21 def make return @file unless @streaming src = @file dst = Tempfile.new([@basename, @format ? ".#{@format}" : '']) dst.binmode parameters = [] # Add source parameters << ":source" # Add destination parameters << ":dest" parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ") Paperclip.log("[qtfaststart] #{parameters}") begin success = Paperclip.run("qt-faststart", parameters, :source => "#{File.(src.path)}", :dest => File.(dst.path)) rescue Cocaine::ExitStatusError => e raise PaperclipError, "error while processing video for #{@basename}: #{e}" if @whiny end dst end |