Class: Abrizer::ProgressiveVp9
- Inherits:
-
Object
- Object
- Abrizer::ProgressiveVp9
show all
- Includes:
- FilepathHelpers
- Defined in:
- lib/abrizer/progressive_vp9.rb
Instance Method Summary
collapse
#audio_filepath, #audio_filepath_fragmented, #basename, #canvas_filepath, #canvas_partial_filepath, #filename_directory, #first_image_filepath, #hlsts_filepath, #hlsts_partial_filepath, #mp4_filepath, #mp4_partial_filepath, #mpd_filepath, #mpd_partial_filepath, #output_directory, #output_directory_basename, #poster_image_filepath, #poster_partial_filepath, #sprites_filepath, #sprites_partial_filepath, #vp9_filepath, #vp9_partial_filepath, #webvtt_input_filepath
Constructor Details
#initialize(filename, output_dir = nil) ⇒ ProgressiveVp9
Returns a new instance of ProgressiveVp9.
6
7
8
9
10
11
12
|
# File 'lib/abrizer/progressive_vp9.rb', line 6
def initialize(filename, output_dir=nil)
@filename = filename
@output_directory = output_dir
make_directory
Dir.chdir @output_directory
find_adaptation
end
|
Instance Method Details
#bitrate ⇒ Object
Since we are using the VP9 as a fallback we use half the bitrate we would use for an MP4 encode.
33
34
35
|
# File 'lib/abrizer/progressive_vp9.rb', line 33
def bitrate
@adaptation.bitrate/2
end
|
#create ⇒ Object
14
15
16
17
|
# File 'lib/abrizer/progressive_vp9.rb', line 14
def create
`#{ffmpeg_cmd_pass1}`
`#{ffmpeg_cmd_pass2}`
end
|
#ffmpeg_cmd_pass1 ⇒ Object
37
38
39
40
41
42
|
# File 'lib/abrizer/progressive_vp9.rb', line 37
def ffmpeg_cmd_pass1
"ffmpeg -y -i #{@filename} -c:v libvpx-vp9 -b:v #{bitrate}k -c:a libvorbis \
-vf scale='#{@adaptation.width}:trunc(#{@adaptation.width}/dar/2)*2',setsar=1 \
-speed 4 -tile-columns 6 -frame-parallel 1 \
-pass 1 -passlogfile ffmpeg2pass-webm -f webm /dev/null"
end
|
#ffmpeg_cmd_pass2 ⇒ Object
44
45
46
47
48
49
|
# File 'lib/abrizer/progressive_vp9.rb', line 44
def ffmpeg_cmd_pass2
"ffmpeg -y -i #{@filename} -c:v libvpx-vp9 -b:v #{bitrate}k -c:a libvorbis \
-vf 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 -y #{static_filepath}"
end
|
#find_adaptation ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/abrizer/progressive_vp9.rb', line 23
def find_adaptation
adaptations = Abrizer::AdaptationFinder.new(@filename).adaptations
sorted = adaptations.sort_by do |adaptation|
adaptation.width
end
@adaptation = sorted.last
end
|
#make_directory ⇒ Object
19
20
21
|
# File 'lib/abrizer/progressive_vp9.rb', line 19
def make_directory
FileUtils.mkdir @output_directory unless File.exist? @output_directory
end
|
#static_filepath ⇒ Object
51
52
53
|
# File 'lib/abrizer/progressive_vp9.rb', line 51
def static_filepath
File.join output_directory, "progressive-vp9.webm"
end
|