Sha256: 188dd80334e34dda9ed66232856da144efba2240831b817154a1f77c2ce6a7ea

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 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 #{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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abrizer-0.4.0 lib/abrizer/progressive_mp4.rb