lib/paperclip/paperclip_processors/transcoder.rb
def make
      ::Av.logger = Paperclip.logger
      @cli.add_source @file
      dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
      dst.binmode

      p "[PAVT] Making..."
      p "[PAVT] Meta info #{@meta}"

      if @meta
        p "[PAVT] Transcoding supported file #{@file.path}"
        @cli.add_source(@file.path)
        @cli.add_destination(dst.path)
        @cli.reset_input_filters

        if output_is_image?
          @time = @time.call(@meta, @options) if @time.respond_to?(:call)
          @cli.filter_seek @time

          if @auto_rotate && !@meta[:rotate].nil?
            p "[PAVT] Adding rotation #{@meta[:rotate]}"
            case @meta[:rotate]
            when 90
              @convert_options[:output][:vf] = "'transpose=1'"
            when 180
              @convert_options[:output][:vf] = "'vflip, hflip'"
            when 270
              @convert_options[:output][:vf] = "'transpose=2'"
            end
          end
        end

        if @convert_options.present?
          if @convert_options[:input]
            @convert_options[:input].each do |h|
              @cli.add_input_param h
            end
          end
          if @convert_options[:output]
            @convert_options[:output].each do |h|
              @cli.add_output_param h
            end
          end
        end

        begin
          @cli.run
          log "Successfully transcoded #{@basename} to #{dst}"
        rescue Cocaine::ExitStatusError => e
          raise Paperclip::Error, "error while transcoding #{@basename}: #{e}" if @whiny
        end
      else
        log "Unsupported file #{@file.path}"
        # If the file is not supported, just return it
        dst << @file.read
        dst.close
      end
      dst
    end
# Performs the transcoding of the +file+ into a thumbnail/video. Returns the Tempfile
# that contains the new image/video.
Performs the transcoding of the +file+ into a thumbnail/video. Returns the Tempfile
that contains the new image/video.
Performs the transcoding of the + file + into a thumbnail / video . Returns the Tempfile that contains the new image / video .
def make
      ::Av.logger = Paperclip.logger
      @cli.add_source @file
      dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
      dst.binmode
      p "[PAVT] Making..."
      p "[PAVT] Meta info #{@meta}"
      if @meta
        p "[PAVT] Transcoding supported file #{@file.path}"
        @cli.add_source(@file.path)
        @cli.add_destination(dst.path)
        @cli.reset_input_filters
        if output_is_image?
          @time = @time.call(@meta, @options) if @time.respond_to?(:call)
          @cli.filter_seek @time
          if @auto_rotate && !@meta[:rotate].nil?
            p "[PAVT] Adding rotation #{@meta[:rotate]}"
            case @meta[:rotate]
            when 90
              @convert_options[:output][:vf] = "'transpose=1'"
            when 180
              @convert_options[:output][:vf] = "'vflip, hflip'"
            when 270
              @convert_options[:output][:vf] = "'transpose=2'"
            end
          end
        end
        if @convert_options.present?
          if @convert_options[:input]
            @convert_options[:input].each do |h|
              @cli.add_input_param h
            end
          end
          if @convert_options[:output]
            @convert_options[:output].each do |h|
              @cli.add_output_param h
            end
          end
        end
        begin
          @cli.run
          log "Successfully transcoded #{@basename} to #{dst}"
        rescue Cocaine::ExitStatusError => e
          raise Paperclip::Error, "error while transcoding #{@basename}: #{e}" if @whiny
        end
      else
        log "Unsupported file #{@file.path}"
        dst << @file.read
        dst.close
      end
      dst
    end
def make :: Av . logger = Paperclip . logger @cli . add_source @file dst = Tempfile . new ( [ @basename , @format ? ".#{@format}" : '' ] ) dst . binmode p "[PAVT] Making..." p "[PAVT] Meta info #{@meta}" if @meta p "[PAVT] Transcoding supported file #{@file.path}" @cli . add_source ( @file . path ) @cli . add_destination ( dst . path ) @cli . reset_input_filters if output_is_image? @time = @time . call ( @meta , @options ) if @time . respond_to? ( :call ) @cli . filter_seek @time if @auto_rotate && ! @meta [ :rotate ] . nil? p "[PAVT] Adding rotation #{@meta[:rotate]}" case @meta [ :rotate ] when 90 @convert_options [ :output ] [ :vf ] = "'transpose=1'" when 180 @convert_options [ :output ] [ :vf ] = "'vflip, hflip'" when 270 @convert_options [ :output ] [ :vf ] = "'transpose=2'" end end end if @convert_options . present? if @convert_options [ :input ] @convert_options [ :input ] . each do | h | @cli . add_input_param h end end if @convert_options [ :output ] @convert_options [ :output ] . each do | h | @cli . add_output_param h end end end begin @cli . run log "Successfully transcoded #{@basename} to #{dst}" rescue Cocaine :: ExitStatusError => e raise Paperclip :: Error , "error while transcoding #{@basename}: #{e}" if @whiny end else log "Unsupported file #{@file.path}" dst << @file . read dst . close end dst end
Performs the transcoding of the +file+ into a thumbnail/video.
Performs the transcoding of the + file + into a thumbnail / video .
# If the file is not supported, just return it