lib/abrizer/adaptation.rb in abrizer-0.3.0 vs lib/abrizer/adaptation.rb in abrizer-0.4.0
- old
+ new
@@ -1,23 +1,25 @@
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 -i #{input} -vf \
- scale='#{width}:trunc(#{width}/dar/2)*2',setsar=1 \
+ 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 |
+ -b:v #{bitrate}k -preset faster -pix_fmt yuv420p |
if pass == 2
cmd += %Q| -maxrate #{constrained_bitrate}k -bufsize #{bitrate}k -pass 2 #{filepath(input, output_directory)} |
else
cmd += " -pass 1 -f mp4 /dev/null "
end
@@ -45,9 +47,17 @@
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