lib/abrizer/progressive_mp4.rb in abrizer-0.4.0 vs lib/abrizer/progressive_mp4.rb in abrizer-0.5.0

- old
+ new

@@ -1,29 +1,32 @@ module Abrizer class ProgressiveMp4 include FilepathHelpers - def initialize(filename, output_dir=nil) - @filename = filename + def initialize(output_dir) @output_directory = output_dir find_adaptation end def create - `#{ffmpeg_cmd}` + if File.exist? input_video_filepath + `#{ffmpeg_cmd}` + else + raise Mp4AdaptationNotFoundError + end end def find_adaptation - adaptations = Abrizer::AdaptationFinder.new(@filename).adaptations + adaptations = Abrizer::AdaptationFinder.new(output_directory: @output_directory).adaptations sorted = adaptations.sort_by do |adaptation| adaptation.width end @adaptation = sorted[-2] end def input_video_filepath - @adaptation.filepath_fragmented(@filename, output_directory) + @adaptation.filepath_fragmented(@output_directory) end 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: