Sha256: 33e3e6775e7f15fc0deb526b466c8d6d882f1c511d54c0d1f3e6b21a3b135da2

Contents?: true

Size: 1.07 KB

Versions: 14

Compression:

Stored size: 1.07 KB

Contents

module Hydra::Derivatives::Processors
  module Video
    class Processor < Hydra::Derivatives::Processors::Processor
      include Ffmpeg

      class_attribute :config
      self.config = Config.new

      protected

        def options_for(format)
          input_options = ""
          output_options = "-s #{config.size_attributes} #{codecs(format)}"

          if format == "jpg"
            input_options += " -itsoffset -2"
            output_options += " -vframes 1 -an -f rawvideo"
          else
            output_options += " #{config.video_attributes} #{config.audio_attributes}"
          end

          { Ffmpeg::OUTPUT_OPTIONS => output_options, Ffmpeg::INPUT_OPTIONS => input_options }
        end

        def codecs(format)
          case format
          when 'mp4'
            config.mpeg4.codec
          when 'webm'
            config.webm.codec
          when "mkv"
            config.mkv.codec
          when "jpg"
            config.jpeg.codec
          else
            raise ArgumentError, "Unknown format `#{format}'"
          end
        end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hydra-derivatives-3.7.0 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.6.1 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.6.0 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.5.0 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.4.2 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.4.1 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.4.0 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.3.2 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.3.1 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.3.0 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.2.2 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.2.1 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.2.0 lib/hydra/derivatives/processors/video/processor.rb
hydra-derivatives-3.1.4 lib/hydra/derivatives/processors/video/processor.rb