Class: Abrizer::PackageDashShaka

Inherits:
Object
  • Object
show all
Includes:
FilepathHelpers
Defined in:
lib/abrizer/package_dash_shaka.rb

Instance Method Summary collapse

Methods included from FilepathHelpers

#adaptations_filepath, #all_media_paths, #audio_filepath, #audio_filepath_fragmented, #basename, #canvas_filepath, #canvas_partial_filepath, #captions_filepath, #data_filepath, #data_partial_filepath, #ffprobe_filepath, #filename_directory, #first_image_filepath, #hlsts_aac_filepath, #hlsts_aac_partial_filepath, #hlsts_filepath, #hlsts_partial_filepath, #mp3_filepath, #mp3_partial_filepath, #mp4_filepath, #mp4_partial_filepath, #mpd_filepath, #mpd_partial_filepath, #output_directory, #output_directory_basename, #poster_filepath, #poster_image_filepath, #poster_partial_filepath, #sprites_filepath, #sprites_partial_filepath, #vp9_filepath, #vp9_partial_filepath, #webvtt_input_filepath

Constructor Details

#initialize(filename, output_dir = nil) ⇒ PackageDashShaka

Returns a new instance of PackageDashShaka.



6
7
8
9
# File 'lib/abrizer/package_dash_shaka.rb', line 6

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

Instance Method Details

#audio_inputObject



26
27
28
29
# File 'lib/abrizer/package_dash_shaka.rb', line 26

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

#dash_directoryObject



43
44
45
# File 'lib/abrizer/package_dash_shaka.rb', line 43

def dash_directory
  File.join output_directory, 'dash'
end

#make_directoryObject



39
40
41
# File 'lib/abrizer/package_dash_shaka.rb', line 39

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

#mpd_filenameObject



31
32
33
# File 'lib/abrizer/package_dash_shaka.rb', line 31

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

#packageObject



11
12
13
14
15
# File 'lib/abrizer/package_dash_shaka.rb', line 11

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

#shaka_cmdObject



35
36
37
# File 'lib/abrizer/package_dash_shaka.rb', line 35

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

#video_inputsObject



17
18
19
20
21
22
23
24
# File 'lib/abrizer/package_dash_shaka.rb', line 17

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