class Abrizer::ProgressiveMp4

Public Class Methods

new(output_dir) click to toggle source
# File lib/abrizer/progressive_mp4.rb, line 6
def initialize(output_dir)
  @output_directory = output_dir
  find_adaptation
end

Public Instance Methods

create() click to toggle source
# File lib/abrizer/progressive_mp4.rb, line 11
def create
  if File.exist? input_video_filepath
    `#{ffmpeg_cmd}`
  else
    raise Mp4AdaptationNotFoundError
  end
end
ffmpeg_cmd() click to toggle source
# File lib/abrizer/progressive_mp4.rb, line 31
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_adaptation() click to toggle source
# File lib/abrizer/progressive_mp4.rb, line 19
def find_adaptation
  adaptations = Abrizer::AdaptationFinder.new(output_directory: @output_directory).adaptations
  sorted = adaptations.sort_by do |adaptation|
   adaptation.width
  end
  @adaptation = sorted[-2]
end
input_video_filepath() click to toggle source
# File lib/abrizer/progressive_mp4.rb, line 27
def input_video_filepath
  @adaptation.filepath_fragmented(@output_directory)
end