How to Use FFmpeg Vocoder Filter

This article explains how to use the vocoder audio filter in FFmpeg to create classic robotic voice effects. You will learn how to prepare your modulator (voice) and carrier (synthesizer) signals, merge them into a single stereo stream, and apply the filter with customized parameters to control the output.

Understanding the Vocoder Inputs

The FFmpeg vocoder filter requires a single stereo input stream where: * Left Channel (Channel 0): The modulator (usually a voice recording or speech). * Right Channel (Channel 1): The carrier (usually a synthesizer chord, noise, or a rich harmonic instrument).

The filter uses the spectral envelope of the Left channel (voice) and applies it to the Right channel (synth) to create the synthesized speaking effect.

The Basic FFmpeg Command

To use the filter, you must first merge your separate voice and synthesizer audio files into a stereo track using the amerge filter, and then pass that combined stream into the vocoder filter.

Here is the standard command:

ffmpeg -i voice.wav -i synth.wav -filter_complex "[0:a][1:a]amerge=inputs=2[stereo];[stereo]vocoder[out]" -map "[out]" output.wav

Command Breakdown:

Customizing Vocoder Parameters

You can fine-tune the vocoder effect using specific parameters. The syntax is vocoder=parameter1=value1:parameter2=value2.

The available parameters are:

Example with Custom Parameters:

To increase the number of bands for a clearer voice and slightly increase the decay time, use the following command:

ffmpeg -i voice.wav -i synth.wav -filter_complex "[0:a][1:a]amerge=inputs=2[stereo];[stereo]vocoder=points=4000:rd=0.05:decay=0.1:gain=1.5[out]" -map "[out]" output_custom.wav