# File lib/paperclip/frame_grab.rb, line 26
    def make
      src = @file
      dst = Tempfile.new([ @basename, @target_format ].compact.join("."))
      dst.binmode

      begin
        # grab frame at offset
        cmd = %Q[-itsoffset #{time_offset} -i :source -y -vcodec mjpeg -vframes 1 -an -f rawvideo ]

        # if scale-and-crop parameters can be calculated, we pipe to convert for resizing
        if scale_and_crop = transformation_options
          cmd << %{pipe: | convert #{scale_and_crop} - #{target_format}:- }

        # otherwise we let ffmpeg resize the to the right size without preserving aspect ratio
        else
          cmd << %{-s #{target_geometry} pipe: }
        end

        # then pipe to composite to overlay video icon
        cmd << %{| composite -gravity center :icon - :dest }
        
        Paperclip.run('ffmpeg', cmd, :source => File.expand_path(src.path), :dest => File.expand_path(dst.path), :icon => AssetType.find(:video).icon_path, :swallow_stderr => false)
      rescue PaperclipCommandLineError => e
        raise PaperclipError, "There was an error processing the thumbnail for #{@basename}: #{e}" if whiny
      end
      
      dst
    end