How to Create a Comb Filter Effect in FFmpeg
This guide explains how to apply a comb filter effect to an audio stream using FFmpeg. You will learn the specific command-line arguments and audio filters required to mix a delayed version of a signal with the original, creating the distinct metallic, hollow sound characteristic of comb filtering.
To create a comb filter effect in FFmpeg, you use the
aecho (audio echo) filter. A comb filter is physically
achieved by adding a delayed version of a signal to itself. When the
delay time is very short—typically between 1 and 15 milliseconds—the
human ear hears spectral coloration (the comb filter effect) rather than
a distinct, separate echo.
The FFmpeg Command
Run the following command in your terminal to apply the effect:
ffmpeg -i input.mp3 -af "aecho=0.8:0.8:6:0.7" output.mp3Parameter Breakdown
The aecho filter uses the syntax
aecho=in_gain:out_gain:delays:decays. To achieve a comb
filter, the parameters should be configured as follows:
in_gain(0.8): Sets the input volume of the original signal. Reducing this slightly prevents digital clipping when the delayed signal is added.out_gain(0.8): Sets the overall output volume of the processed signal.delays(6): Specifies the delay time in milliseconds. For a comb filter effect, this value must be very low (ideally between1and15). A delay of6ms creates a series of peaks and notches in the frequency spectrum, resulting in a metallic timbre.decays(0.7): Sets the volume of the delayed signal relative to the original. A value closer to1.0makes the comb filtering peaks and notches deeper and more pronounced.
Creating a Flanging Effect (Modulated Comb Filter)
If you want a dynamic, moving comb filter (known as a flanger), you
can use FFmpeg’s aphaser filter instead. This modulates the
delay time automatically:
ffmpeg -i input.mp3 -af "aphaser=type=t:decay=0.6:speed=0.5:delay=3" output.mp3In this command, delay=3 sets a 3-millisecond base
delay, while speed=0.5 modulates the sweep of the comb
filter at 0.5 Hz, creating a classic sweeping psychedelic effect.