How to Use the FFmpeg Vocoder Filter

This guide explains how to configure and apply the vocoder filter in FFmpeg to create classic robotic vocal effects and synthetic speech. You will learn the mechanics behind the two-input vocoder design, the essential parameters available for shaping the sound, and the exact command-line syntax required to process your audio files.

Understanding the Inputs: Carrier and Modulator

The FFmpeg vocoder filter operates by imposing the spectral envelope of one audio signal onto another. It requires two separate audio streams mapped through FFmpeg's -filter_complex:

  1. Carrier (Input 0): The base musical tone or sound source that provides pitch and timbre (such as a synthesizer pad, sustained chord, or saw wave).
  2. Modulator (Input 1): The signal that provides speech, articulation, or rhythm (typically a spoken vocal track).

Filter Parameters

The vocoder filter accepts several parameters to control the frequency splitting and envelope behavior:

  • bands: Sets the number of frequency bands for filtering. The value ranges from 4 to 240 (default is 16). Higher values provide clearer speech intelligibility, while lower values produce a more vintage, heavily processed effect.
  • attack: Sets the envelope follower attack time in milliseconds (range: 0.1 to 500.0, default is 1.0). A shorter attack responds faster to consonants.
  • release: Sets the envelope follower release time in milliseconds (range: 0.1 to 500.0, default is 1.0). Longer values result in smoother, lingering transitions between syllables.

Basic Command-Line Syntax

To run the filter, pass your carrier audio as the first input and your voice audio as the second input. Map them into the filter graph in that exact order:

ffmpeg -i carrier.wav -i speech.wav -filter_complex "[0:a][1:a]vocoder=bands=32:attack=5:release=20[aout]" -map "[aout]" output.wav

In this example:

  • [0:a] assigns the audio stream from carrier.wav to the carrier input.
  • [1:a] assigns the audio stream from speech.wav to the modulator input.
  • bands=32 increases the frequency bands from the default for enhanced intelligibility.
  • attack=5 and release=20 provide a smooth natural envelope following the voice.

Advanced Usage and Tuning

High-Intelligibility Configuration

For clearer speech where lyrics or spoken words must remain easy to understand, increase the band count:

ffmpeg -i synth.wav -i voice.wav -filter_complex "[0:a][1:a]vocoder=bands=64:attack=2:release=10[out]" -map "[out]" output.wav

Vintage Robotic Sound

To emulate classic early hardware vocoders, reduce the number of bands and use quick envelope times:

ffmpeg -i synth.wav -i voice.wav -filter_complex "[0:a][1:a]vocoder=bands=8:attack=1:release=5[out]" -map "[out]" output.wav

Handling Differing Audio Lengths

If your carrier audio is shorter or longer than the speech, use the apad or atrim filter, or add the -shortest flag to cut the output as soon as the voice finishes:

ffmpeg -i synth.wav -i voice.wav -filter_complex "[0:a][1:a]vocoder=bands=24:attack=3:release=15[out]" -map "[out]" -shortest output.wav