Sha256: 7adbf1ebc8312745717b27fbfd285348c79a4eb7cd370d327e2ce20df5420ee0

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

module Abrizer
  class PackageDashShaka

    include FilepathHelpers

    def initialize(filename, output_dir=nil)
      @filename = filename
      @adaptations = Abrizer::AdaptationFinder.new(filepath: @filename).adaptations
    end

    def package
      make_directory
      Dir.chdir output_directory
      `#{shaka_cmd}`
    end

    def video_inputs
      @adaptations.map do |adaptation|
        filepath = adaptation.filepath(@filename)
        adaptation_basename = File.basename filepath, '.mp4'
        output_filename = File.join 'dash', "#{adaptation_basename}-dash.mp4"
        %Q|"input=#{filepath},stream=video,output=#{output_filename}"|
      end
    end

    def audio_input
      dash_audio_filename = File.join 'dash', "#{basename}-audio-dash.m4a"
      "input=#{audio_filepath},stream=audio,output=#{dash_audio_filename}"
    end

    def mpd_filename
      File.join 'dash', "#{basename}.mpd"
    end

    def shaka_cmd
      %Q|shaka-packager #{video_inputs.join(' ')} #{audio_input} --profile on-demand --mpd_output #{mpd_filename}|
    end

    def make_directory
      FileUtils.mkdir_p dash_directory unless File.exist? dash_directory
    end

    def dash_directory
      File.join output_directory, 'dash'
    end


  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
abrizer-0.6.0 lib/abrizer/package_dash_shaka.rb
abrizer-0.5.0 lib/abrizer/package_dash_shaka.rb