class Abrizer::ProgressiveVp9
Public Class Methods
new(filename, output_dir=nil)
click to toggle source
# File lib/abrizer/progressive_vp9.rb, line 7 def initialize(filename, output_dir=nil) @filename = filename @output_directory = output_dir make_directory Dir.chdir @output_directory find_adaptation end
Public Instance Methods
bitrate()
click to toggle source
Since we are using the VP9 as a fallback we use half the bitrate we would use for an MP4 encode.
# File lib/abrizer/progressive_vp9.rb, line 34 def bitrate @adaptation.bitrate/2 end
create()
click to toggle source
# File lib/abrizer/progressive_vp9.rb, line 15 def create `#{ffmpeg_cmd_pass1}` `#{ffmpeg_cmd_pass2}` end
ffmpeg_cmd_pass1()
click to toggle source
# File lib/abrizer/progressive_vp9.rb, line 38 def ffmpeg_cmd_pass1 "ffmpeg -y #{debug_settings} -i #{@filename} -c:v libvpx-vp9 -crf 10 -b:v #{bitrate*1.1}k -c:a libvorbis \ -vf yadif,scale='#{@adaptation.width}:trunc(#{@adaptation.width}/dar/2)*2',setsar=1 \ -speed 4 -tile-columns 6 -frame-parallel 1 -pix_fmt yuv420p \ -pass 1 -passlogfile ffmpeg2pass-webm -f webm /dev/null" end
ffmpeg_cmd_pass2()
click to toggle source
# File lib/abrizer/progressive_vp9.rb, line 45 def ffmpeg_cmd_pass2 "ffmpeg -y #{debug_settings} -i #{@filename} -c:v libvpx-vp9 -crf 10 -b:v #{bitrate*1.1}k -c:a libvorbis \ -vf yadif,scale='#{@adaptation.width}:trunc(#{@adaptation.width}/dar/2)*2',setsar=1 \ -speed 1 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 \ -pass 2 -passlogfile ffmpeg2pass-webm -pix_fmt yuv420p #{static_filepath}" end
find_adaptation()
click to toggle source
# File lib/abrizer/progressive_vp9.rb, line 24 def find_adaptation adaptations = Abrizer::AdaptationFinder.new(filepath: @filename).adaptations sorted = adaptations.sort_by do |adaptation| adaptation.width end @adaptation = sorted.last end
make_directory()
click to toggle source
# File lib/abrizer/progressive_vp9.rb, line 20 def make_directory FileUtils.mkdir_p @output_directory unless File.exist? @output_directory end
static_filepath()
click to toggle source
# File lib/abrizer/progressive_vp9.rb, line 52 def static_filepath File.join output_directory, "progressive-vp9.webm" end