Sha256: ff576e6b2052b1e76c5f9e19f5417d5a4c7c9f3aa364a17091181f9b13afe828

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 KB

Contents

module CarrierWave
  module Video
    class FfmpegTheora
      attr_reader :input_path, :output_path
      def initialize(input_file_path, output_file_path)
        @input_path = input_file_path
        @output_path = output_file_path
      end

      def run(logger=nil)
        cmd = "#{CarrierWave::Video.ffmpeg2theora_binary} #{input_path} -o #{output_path}"
        logger.info("Running....#{cmd}") if logger
        outputs = []
        exit_code = nil

        Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
          stderr.each("r") do |line|
            outputs << line
          end
          exit_code = wait_thr.value
        end

        handle_exit_code(exit_code, outputs, logger)
      end

      private
      def handle_exit_code(exit_code, outputs, logger)
        return unless logger
        if exit_code == 0
          logger.info("Success!")
        else
          outputs.each do |output|
            logger.error(output)
          end
          logger.error("Failure!")
        end
        exit_code
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
carrierwave-video-0.6.0 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.5.6 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.5.5 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.5.4 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.5.3 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.5.2 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.5.1 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.5.0 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.4.0 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.3.0 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.2.3 lib/carrierwave/video/ffmpeg_theora.rb
carrierwave-video-0.2.2 lib/carrierwave/video/ffmpeg_theora.rb