Class: Abrizer::Captions
- Inherits:
-
Object
- Object
- Abrizer::Captions
- 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
- #copy ⇒ Object
-
#initialize(filename, output_dir) ⇒ Captions
constructor
A new instance of Captions.
- #vtt_dir_glob ⇒ Object
-
#vtt_file_glob ⇒ Object
TODO: actually search for more than one VTT file.
- #vtt_output_directory ⇒ Object
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) ⇒ Captions
Returns a new instance of Captions.
10 11 12 13 14 15 16 |
# File 'lib/abrizer/captions.rb', line 10 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
#copy ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/abrizer/captions.rb', line 18 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_glob ⇒ Object
26 27 28 |
# File 'lib/abrizer/captions.rb', line 26 def vtt_dir_glob Dir.glob vtt_file_glob end |
#vtt_file_glob ⇒ Object
TODO: actually search for more than one VTT file
31 32 33 |
# File 'lib/abrizer/captions.rb', line 31 def vtt_file_glob File.join filename_directory, "#{basename}.vtt" end |
#vtt_output_directory ⇒ Object
35 36 37 |
# File 'lib/abrizer/captions.rb', line 35 def vtt_output_directory File.join @output_directory, 'vtt' end |