Class: Abrizer::Captions

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

Overview

Copies over any WebVTT captions that are beside the original video resource into the destination folder. TODO: This may only be needed if fMP4 derivatives aren’t created since captions are copied over. TODO: Allow for more than one captions/subtitle file to be copied over.

Instance Method Summary collapse

Methods included from FilepathHelpers

#adaptations_filepath, #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) ⇒ Captions

Returns a new instance of Captions.



11
12
13
14
15
16
17
# File 'lib/abrizer/captions.rb', line 11

def initialize(filename, output_dir)
  @filename = filename
  @output_directory = output_dir
  if vtt_dir_glob.length > 0
    FileUtils.mkdir_p vtt_output_directory
  end
end

Instance Method Details

#copyObject



19
20
21
22
23
24
25
# File 'lib/abrizer/captions.rb', line 19

def copy
  vtt_dir_glob.each do |vtt|
    # vtt_basename = File.basename vtt
    vtt_filename = File.join vtt_output_directory, 'captions.vtt'
    FileUtils.cp vtt, vtt_filename
  end
end

#vtt_dir_globObject



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

def vtt_dir_glob
  Dir.glob vtt_file_glob
end

#vtt_file_globObject

TODO: actually search for more than one VTT file



32
33
34
# File 'lib/abrizer/captions.rb', line 32

def vtt_file_glob
  File.join filename_directory, "#{basename}.vtt"
end

#vtt_output_directoryObject



36
37
38
# File 'lib/abrizer/captions.rb', line 36

def vtt_output_directory
  File.join @output_directory, 'vtt'
end