Sha256: 2b131d19982d77dce09493867628474386d7d3f2204c5920bf7bfbc238011ad6

Contents?: true

Size: 828 Bytes

Versions: 5

Compression:

Stored size: 828 Bytes

Contents

module Hydra
  module Derivatives
    class Video < Processor
      include Ffmpeg

      protected

      def options_for(format)
        "-s #{size_attributes} #{video_attributes} #{codecs(format)} #{audio_attributes}"
      end

      def video_bitrate
        '345k'
      end

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

      def size_attributes
        "320x240"
      end

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

      def codecs(format)
        case format
        when 'mp4'
          "-vcodec libx264 -acodec libfaac"
        when 'webm'
          "-acodec libvorbis"
        else
          raise ArgumentError, "Unknown format `#{format}'"
        end
      end

      def new_mime_type(format)
        "video/#{format}"
      end
    end
  end
end


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydra-derivatives-0.0.5 lib/hydra/derivatives/video.rb
hydra-derivatives-0.0.4 lib/hydra/derivatives/video.rb
hydra-derivatives-0.0.3 lib/hydra/derivatives/video.rb
hydra-derivatives-0.0.2 lib/hydra/derivatives/video.rb
hydra-derivatives-0.0.1 lib/hydra/derivatives/video.rb