Skip to content

Instantly share code, notes, and snippets.

@erik-krogh
Created October 9, 2022 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erik-krogh/5d8d5cbc9c776b21367a0e36b3d5c550 to your computer and use it in GitHub Desktop.
Save erik-krogh/5d8d5cbc9c776b21367a0e36b3d5c550 to your computer and use it in GitHub Desktop.

discordrb/discordrb

lib/discordrb/voice/encoder.rb

    # @return [IO] the audio, encoded as s16le PCM
    def encode_file(file, options = '')
      command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" #{options} -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
      IO.popen(command)
    end

This string construction which depends on library input is later used in a shell command.

Paths

Path with 2 steps
  1. lib/discordrb/voice/encoder.rb

        # @param options [String] ffmpeg options to pass after the -i flag
         # @return [IO] the audio, encoded as s16le PCM
         def encode_file(file, options = '')
           command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" #{options} -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
           IO.popen(command)
     
  2. lib/discordrb/voice/encoder.rb

        # @return [IO] the audio, encoded as s16le PCM
         def encode_file(file, options = '')
           command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" #{options} -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
           IO.popen(command)
         end
     

lib/discordrb/voice/encoder.rb

    # @return [IO] the audio, encoded as s16le PCM
    def encode_file(file, options = '')
      command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" #{options} -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
      IO.popen(command)
    end

This string construction which depends on library input is later used in a shell command.

Paths

Path with 2 steps
  1. lib/discordrb/voice/encoder.rb

        # @param options [String] ffmpeg options to pass after the -i flag
         # @return [IO] the audio, encoded as s16le PCM
         def encode_file(file, options = '')
           command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" #{options} -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
           IO.popen(command)
     
  2. lib/discordrb/voice/encoder.rb

        # @return [IO] the audio, encoded as s16le PCM
         def encode_file(file, options = '')
           command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" #{options} -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
           IO.popen(command)
         end
     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment