How to Use the FFmpeg Vocoder Filter
This article provides a straightforward guide on how to use the
vocoder filter in FFmpeg to apply a classic robotic voice
effect to your audio. You will learn the fundamental mechanics of how
the filter processes audio, the key parameters you can adjust, and
practical command-line examples for combining voice and carrier signals
on the fly.
Understanding the FFmpeg Vocoder Filter
The vocoder filter in FFmpeg requires a stereo input to
function. It uses one channel as the modulator
(typically a human voice) and the other channel as the
carrier (typically a synthesizer, instrument, or
noise).
By default: * The Left channel is treated as the modulator (speech). * The Right channel is treated as the carrier (synthesizer).
The filter analyzes the frequency characteristics of the modulator and applies them to the carrier, resulting in the classic “talking synthesizer” effect.
Basic Filter Parameters
You can customize the effect using the following parameters:
bands: Sets the number of frequency bands (default is30). A higher number of bands (up to 240) makes the speech more intelligible, while a lower number makes it sound more abstract and robotic.scale: Sets the output gain scale (default is1.0).cutoff: Sets the carrier bandpass cutoff frequency in Hz (default is20000).pitch: Sets the pitch scale (default is1.0).
Practical Command Examples
Example 1: Applying Vocoder to a Pre-Prepared Stereo File
If you already have a stereo audio file where the left channel contains the voice and the right channel contains the synthesizer, use this simple command:
ffmpeg -i input_stereo.wav -af "vocoder=bands=40:scale=1.5" output.wavExample 2: Combining Two Separate Files (Voice and Synth)
Most of the time, your voice and synthesizer tracks will be in
separate files. You can use the amerge filter to combine
them into a single stereo stream before passing them to the
vocoder filter:
ffmpeg -i voice.wav -i synth.wav -filter_complex "[0:a][1:a]amerge=inputs=2[stereo];[stereo]vocoder=bands=40:scale=1.2[out]" -map "[out]" output.wavIn this command: 1. -i voice.wav is input 0 (the
modulator). 2. -i synth.wav is input 1 (the carrier). 3.
amerge=inputs=2 merges the two mono inputs into a single
stereo stream where voice.wav becomes the left channel and
synth.wav becomes the right channel. 4.
vocoder processes this combined stream to generate the
final effect.