Class: Abrizer::ProgressiveMp4

Inherits:
Object
  • Object
show all
Includes:
FilepathHelpers
Defined in:
lib/abrizer/progressive_mp4.rb

Instance Method Summary collapse

Methods included from FilepathHelpers

#adaptations_filepath, #audio_filepath, #audio_filepath_fragmented, #basename, #canvas_filepath, #canvas_partial_filepath, #captions_filepath, #data_filepath, #data_partial_filepath, #ffprobe_filepath, #filename_directory, #first_image_filepath, #hlsts_aac_filepath, #hlsts_aac_partial_filepath, #hlsts_filepath, #hlsts_partial_filepath, #mp3_filepath, #mp3_partial_filepath, #mp4_filepath, #mp4_partial_filepath, #mpd_filepath, #mpd_partial_filepath, #output_directory, #output_directory_basename, #poster_filepath, #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) ⇒ ProgressiveMp4

Returns a new instance of ProgressiveMp4.



6
7
8
9
10
# File 'lib/abrizer/progressive_mp4.rb', line 6

def initialize(filename, output_dir=nil)
  @filename = filename
  @output_directory = output_dir
  find_adaptation
end

Instance Method Details

#createObject



12
13
14
# File 'lib/abrizer/progressive_mp4.rb', line 12

def create
  `#{ffmpeg_cmd}`
end

#ffmpeg_cmdObject



28
29
30
31
32
# File 'lib/abrizer/progressive_mp4.rb', line 28

def ffmpeg_cmd
  "ffmpeg -y -i #{input_video_filepath} -i #{audio_filepath_fragmented} -c:v copy -c:a copy #{mp4_filepath} -movflags faststart"
  # Previously used command:
  # "ffmpeg -y -i #{@filename} -profile:v high -pix_fmt yuv420p -movflags faststart -b:v #{@adaptation.bitrate}k #{mp4_filepath}"
end

#find_adaptationObject



16
17
18
19
20
21
22
# File 'lib/abrizer/progressive_mp4.rb', line 16

def find_adaptation
  adaptations = Abrizer::AdaptationFinder.new(@filename).adaptations
  sorted = adaptations.sort_by do |adaptation|
   adaptation.width
  end
  @adaptation = sorted[-2]
end

#input_video_filepathObject



24
25
26
# File 'lib/abrizer/progressive_mp4.rb', line 24

def input_video_filepath
  @adaptation.filepath_fragmented(@filename, output_directory)
end