class Paperclip::Qtfaststart
Attributes
format[RW]
streaming[RW]
whiny[RW]
Public Class Methods
new(file, options = {})
click to toggle source
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.
# File lib/paperclip_processors/qtfaststart.rb, line 8 def initialize file, options = {}, attachment = nil @streaming = options[:streaming] @file = file @whiny = options[:whiny].nil? ? true : options[:whiny] @format = options[:format] @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) attachment.instance_write(:meta, @meta) end
Public Instance Methods
make()
click to toggle source
Performs the atom repositioning on file
. Returns the Tempfile that contains the new video or the original file if streaming
wasn’t set.
# 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.expand_path(src.path)}", :dest => File.expand_path(dst.path)) rescue Cocaine::ExitStatusError => e raise PaperclipError, "error while processing video for #{@basename}: #{e}" if @whiny end dst end