How to Use the FFmpeg firequalizer Filter
The firequalizer filter in FFmpeg is a powerful audio
filter used to adjust the frequency response of an audio stream using a
Finite Impulse Response (FIR) equalizer. This article provides a clear,
step-by-step guide on how to configure and use the
firequalizer filter, detailing its syntax, primary
parameters, and practical command-line examples for boosting, cutting,
or shaping specific audio frequencies.
Understanding the firequalizer Filter
Unlike standard parametric equalizers, firequalizer
allows you to define custom frequency response curves using mathematical
formulas or specific coordinate points (gain entries). It operates in
the frequency domain, offering high precision and flexibility for audio
mastering, noise reduction, and sound design.
The filter is configured primarily through two parameters: *
gain: A mathematical expression that
defines the gain (in dB) as a function of frequency f. *
gain_entry: A list of specific frequency
and gain pairs, which FFmpeg interpolates to create a smooth
equalization curve.
Method 1: Using gain_entry (Point-by-Point Equalization)
The gain_entry parameter is the most intuitive way to
shape audio. You define specific points using the format
entry(frequency, gain). FFmpeg automatically connects these
points with a smooth curve.
Example 1: Bass Boost
To boost frequencies below 100 Hz by 6 dB and leave frequencies above 200 Hz untouched (0 dB):
ffmpeg -i input.mp3 -af "firequalizer=gain_entry='entry(0, 6); entry(100, 6); entry(200, 0)'" output.mp3Example 2: High-Pass Filter (Low-Cut)
To completely cut rumble and low-end noise below 80 Hz:
ffmpeg -i input.mp3 -af "firequalizer=gain_entry='entry(0, -inf); entry(80, -inf); entry(120, 0)'" output.mp3Example 3: Multi-Band Equalizer
You can chain multiple entries together to create complex curves, such as a “smiley face” curve that boosts bass and treble while scooping the mids:
ffmpeg -i input.mp3 -af "firequalizer=gain_entry='entry(0, 6); entry(100, 4); entry(1000, -4); entry(10000, 4); entry(20000, 6)'" output.mp3Method 2: Using gain (Mathematical Expressions)
The gain parameter allows you to use mathematical
expressions to define the equalization curve. The variable
f represents the frequency.
Example 1: Simple Low-Pass Filter
To apply a low-pass filter where frequencies above 1000 Hz are attenuated by 20 dB:
ffmpeg -i input.mp3 -af "firequalizer=gain='if(gte(f,1000), -20, 0)'" output.mp3Example 2: Linear Gain Reduction
To gradually reduce gain as the frequency increases (creating a warmer sound):
ffmpeg -i input.mp3 -af "firequalizer=gain='-0.001*f'" output.mp3Advanced Parameters
To fine-tune how the firequalizer processes audio, you
can append additional parameters:
scale: Sets the scale used for frequency interpolation. Options includelin(linear),log(logarithmic), andsinh(hyperbolic sine). Logarithmic is recommended for audio as it matches human hearing.delay: Sets the filter delay in seconds (default is 0.05). Higher values provide more accurate frequency resolution, especially at low frequencies, but increase latency.accuracy: Defines the FFT accuracy. Default is 0.005.
Example: Logarithmic Multi-Band Equalizer with Custom Delay
This configuration uses a logarithmic scale for smoother natural crossovers and a longer delay for better low-frequency accuracy:
ffmpeg -i input.mp3 -af "firequalizer=delay=0.1:scale=log:gain_entry='entry(0, 5); entry(200, 0); entry(4000, -3); entry(20000, 5)'" output.mp3