Method: RFF::AudioHandler#initialize

Defined in:
lib/audio_handler.rb

#initialize(input, output_path = nil, custom_args = nil, recommended_audio_quality = true, disable_subtitles_decoding = true) ⇒ AudioHandler

This constructor initializes the class with the following arguments:

  • input (required) - the full path to the input file

  • output_path - a path to place the output file in. Defaults to nil, which means that the input’ s directory path is used

  • custom_args - passes custom arguments to FFmpeg. Defaults to nil, which means no custom arguments are given

  • recommended_audio_quality - determines if recommended by FFmpeg community audio quality settings should be used. Defaults to true, which means audio conversion with good, recommended quality. Set to false if you are giving additional arguments that determine this quality.

  • disable_subtitles_decoding - in some formats subtitle decoding causes problems. This option disables this feature. Defaults to true to bypass problems by default.

All of the arguments are passed on to underlying Processor instances. This method also determines input type, initializes processing percentage and creates needed Processor instances.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/audio_handler.rb', line 22

def initialize input, output_path=nil, custom_args=nil, recommended_audio_quality=true, disable_subtitles_decoding=true
  @input = input
  @input_type = File.basename(@input).split(".")[1]
  @output_path = output_path
  @custom_args = custom_args
  @processing_percentage = 0
  @processors = []
  types = [:mp3, :ogg, :wav]
  if !@output_path.nil? && !File.exists?(@output_path)
      FileUtils.mkdir_p(@output_path)
  end
  if types.include?(@input_type.to_sym)
    types.delete(@input_type.to_sym)
    if !@output_path.nil?
        FileUtils.cp @input, @output_path
    end
  end
  types.each do |type|
    @processors << RFF::Processor.new(@input, type, @output_path, nil, @custom_args, recommended_audio_quality, disable_subtitles_decoding)
  end
  @handler_status = :ready
end