Sha256: 4c8447b5eb835f97f8a4fb8c9bdf06b214b1bb3c85c9fecb403ede984a17c60e

Contents?: true

Size: 820 Bytes

Versions: 3

Compression:

Stored size: 820 Bytes

Contents

module Abrizer
  class ProgressiveMp4

    include FilepathHelpers

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

    def create
      `#{ffmpeg_cmd}`
    end

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

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

    def ffmpeg_cmd
      "ffmpeg -y -i #{input_video_filepath} -i #{audio_filepath_fragmented} -c:v copy -c:a copy #{static_filepath}"
    end

    def static_filepath
      File.join output_directory, "progressive.mp4"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
abrizer-0.3.0 lib/abrizer/progressive_mp4.rb
abrizer-0.2.0 lib/abrizer/progressive_mp4.rb
abrizer-0.1.0 lib/abrizer/progressive_mp4.rb