How to Use FFmpeg afir Filter to Apply FIR Filters
This guide explains how to use the afir (Finite Impulse
Response) filter in FFmpeg to apply audio impulse responses to your
audio files. You will learn the basic command-line syntax, key
parameters for controlling wet/dry mix and volume, and how to combine
input audio with impulse response (IR) files to achieve effects like
convolution reverb, cabinet simulation, or custom equalization.
Understanding the afir Filter
The afir filter works by convolving an input audio
stream with an impulse response stream. This process requires two
inputs: the main audio signal you want to process, and an audio file
containing the impulse response (usually a WAV file representing a room,
an amplifier, or an analog filter).
Basic Command Syntax
Because the afir filter requires two separate audio
inputs, you must use FFmpeg’s -filter_complex flag to map
them correctly.
Here is the fundamental command structure:
ffmpeg -i input.wav -i response.wav -filter_complex "[0:a][1:a]afir[out]" -map "[out]" output.wavIn this command: * -i input.wav is the dry audio source
(Input 0). * -i response.wav is the impulse response file
(Input 1). * [0:a][1:a] feeds the audio from the first and
second inputs into the filter. * afir processes the
convolution. * -map "[out]" ensures only the filtered audio
is written to the output file.
Key afir Parameters
You can customize the output of the filter by appending options separated by colons.
Dry and Wet Mix
By default, the filter outputs only the processed (wet) signal. You
can mix the original (dry) signal back in using the dry and
wet options, which accept linear values or decibel values
(e.g., 10dB or 0.5).
ffmpeg -i input.wav -i response.wav -filter_complex "[0:a][1:a]afir=dry=-6dB:wet=-3dB[out]" -map "[out]" output.wavOutput Gain (gblur)
Convolution can significantly alter the volume of the output signal.
The gblur parameter controls the gain envelope blur.
Setting this to 0 disables automatic gain adjustment, which
is helpful if you want to preserve the exact amplitude of your impulse
response:
ffmpeg -i input.wav -i response.wav -filter_complex "[0:a][1:a]afir=gblur=0[out]" -map "[out]" output.wavSetting the IR Power (irpower)
You can choose how the impulse response power is normalized using the
irpower parameter. * irpower=1 (default):
Normalizes the impulse response power, preventing extreme volume spikes.
* irpower=0: Disables normalization, applying the raw
coefficients of the IR file.
Handling Multi-Channel Audio
If your input audio and impulse response files have different channel layouts (for example, a stereo input and a mono impulse response), FFmpeg will automatically try to match them.
However, you can manually define how channels are mapped using the
response option. Enabling response=1 will show
the frequency response of the filter in the command-line interface,
helping you diagnose channel routing and phase issues.