Sha256: 0c726bdc8ddcbac0593a40d42a8497c1765780a0a2531c6bd1a67e8a2c4312bf

Contents?: true

Size: 1.31 KB

Versions: 11

Compression:

Stored size: 1.31 KB

Contents

module Hydra::Derivatives::Processors::Video
  class Config
    attr_writer :video_bitrate, :video_attributes, :size_attributes, :audio_attributes

    def video_bitrate
      @video_bitrate ||= default_video_bitrate
    end

    def video_attributes
      @video_attributes ||= default_video_attributes
    end

    def size_attributes
      @size_attributes ||= default_size_attributes
    end

    def audio_attributes
      @audio_attributes ||= default_audio_attributes
    end

    def mpeg4
      audio_encoder = Hydra::Derivatives::AudioEncoder.new
      @mpeg4 ||= CodecConfig.new("-vcodec libx264 -acodec #{audio_encoder.audio_encoder}")
    end

    def webm
      @webm ||= CodecConfig.new('-vcodec libvpx -acodec libvorbis')
    end

    def mkv
      @mkv ||= CodecConfig.new('-vcodec ffv1')
    end

    def jpeg
      @jpeg ||= CodecConfig.new('-vcodec mjpeg')
    end

    class CodecConfig
      attr_writer :codec

      def initialize(default)
        @codec = default
      end

      attr_reader :codec
    end

    protected

      def default_video_bitrate
        '345k'
      end

      def default_video_attributes
        "-g 30 -b:v #{video_bitrate}"
      end

      def default_size_attributes
        "320x240"
      end

      def default_audio_attributes
        "-ac 2 -ab 96k -ar 44100"
      end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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