How to Use the FFmpeg afir Convolver Filter
This article explains how to apply audio convolution using the FFmpeg
afir filter to process an audio stream with an Impulse
Response (IR). Convolution allows you to replicate physical acoustic
spaces, simulate guitar cabinets, or apply precise frequency filtering
by convolving a primary audio signal with an IR audio file. Below, you
will find the fundamental command syntax, essential parameters, and
practical examples for integrating afir into your audio
processing workflow.
Understanding the Basic Syntax
The afir filter requires at least two audio inputs: the
primary audio stream (input 0) and the impulse response stream (input
1). Because it accepts multiple inputs, it must be invoked using
-filter_complex.
The minimal command structure is:
ffmpeg -i input.wav -i impulse_response.wav -filter_complex "[0:a][1:a]afir[out]" -map "[out]" output.wavIn this command:
-i input.wav: The dry audio signal to be processed.-i impulse_response.wav: The impulse response file (e.g., a room reverb or speaker cabinet profile).[0:a][1:a]afir[out]: Feeds both streams into theafirfilter and outputs a labeled stream[out].-map "[out]": Directs the processed filter output to the final file.
Key Parameters of the
afir Filter
You can customize the behavior of the convolution using parameter pairs separated by colons:
dry: Sets the gain level for the original, unprocessed signal (default is1).wet: Sets the gain level for the convolved signal (default is1).length: Defines the maximum percentage of the impulse response to use (range0.0to1.0, default is1.0).irnorm: Automatically normalizes the impulse response to prevent excessive clipping (default is1). Set to0to disable.irgain: Sets an additional gain multiplier for the impulse response.irfmt: Specifies channel handling between input and impulse response. Options includemono(applies a single IR channel to all input channels) orinput(matches input channels with corresponding IR channels).
Practical Examples
1. Wet/Dry Balance for Reverb
When applying room reverb, you often want a blend of both the original audio and the reverberated sound:
ffmpeg -i speech.wav -i room_ir.wav -filter_complex "[0:a][1:a]afir=dry=1.0:wet=0.3[out]" -map "[out]" speech_reverb.wav2. Full Wet Convolution (Cabinet Simulation or EQ)
For speaker cabinet emulation or custom EQ curves, the direct signal must be completely replaced by the filtered signal:
ffmpeg -i guitar_di.wav -i cab_ir.wav -filter_complex "[0:a][1:a]afir=dry=0:wet=1.0[out]" -map "[out]" guitar_amped.wav3. Preventing Volume Surges with IR Normalization
Long or uncalibrated impulse responses can significantly boost audio
levels. Ensure irnorm is active and optionally lower the
irgain:
ffmpeg -i input.mp3 -i hall_ir.wav -filter_complex "[0:a][1:a]afir=dry=0.8:wet=0.5:irnorm=1:irgain=0.8[a]" -map "[a]" output.mp34. Applying a Mono Impulse Response to a Stereo Track
If your impulse response is mono but the target track is stereo, set
irfmt=mono so the filter duplicates the impulse response
across all channels:
ffmpeg -i stereo_track.wav -i mono_ir.wav -filter_complex "[0:a][1:a]afir=irfmt=mono[out]" -map "[out]" stereo_convolved.wav