Sha256: 3352dfcf98dd3152327bbe598cccf4dc9df7723100ef1344888e8dc044652b29
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module Abrizer class Adaptation include FilepathHelpers include DebugSettings attr_reader :width, :height, :bitrate def initialize(width:, height:, bitrate:) @width = width @height = height @bitrate = bitrate end def ffmpeg_cmd(input, output_directory, pass) cmd = %Q|ffmpeg -y #{debug_settings} \ -i #{input} -vf \ yadif,scale='#{width}:trunc(#{width}/dar/2)*2',setsar=1 \ -an -c:v libx264 -x264opts 'keyint=48:min-keyint=48:no-scenecut' \ -b:v #{bitrate}k -preset faster -pix_fmt yuv420p | if pass == 2 cmd += %Q| -maxrate #{constrained_bitrate}k -bufsize #{bitrate}k -pass 2 #{filepath(output_directory)} | else cmd += " -pass 1 -f mp4 /dev/null " end cmd end # TODO: make the constrained bitrate (maxrate) value configurable def constrained_bitrate @bitrate * 1.1 end def outfile_basename "adaptation-#{width}x#{height}-#{bitrate}" end def filepath(output_directory) name = "#{outfile_basename}.mp4" File.join output_directory, name end def filepath_fragmented(output_directory) name = "#{outfile_basename}-frag.mp4" File.join output_directory, name end def to_s "Width: #{@width}, Height: #{@height}, Bitrate: #{@bitrate}" end def to_json MultiJson.dump(to_hash) end def to_hash {width: @width, height: @height, bitrate: @bitrate} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
abrizer-0.6.0 | lib/abrizer/adaptation.rb |
abrizer-0.5.0 | lib/abrizer/adaptation.rb |