How to Use the FFmpeg Parametric Equalizer Filter

This article provides a straightforward guide on how to configure a parametric equalizer in FFmpeg using the equalizer audio filter. You will learn the syntax of the filter, understand its key parameters (frequency, bandwidth, and gain), and see practical examples of how to apply both single and multiple frequency adjustments to your audio files.

Understanding the FFmpeg Equalizer Filter Syntax

The equalizer filter in FFmpeg is a second-order IIR peaking equalizer. It allows you to boost or attenuate specific frequencies around a chosen center frequency.

The basic syntax for the filter is:

equalizer=f=FREQUENCY:width_type=TYPE:w=WIDTH:g=GAIN

Key Parameters:

  • f (frequency): The center frequency in Hz that you want to adjust (e.g., 1000 for 1 kHz).
  • width_type (t): Specifies how the bandwidth of the filter is defined. Options include:
    • h: Hz (default)
    • q: Q-Factor (commonly used in parametric EQ design)
    • o: Octaves
  • w (width): The bandwidth value corresponding to the chosen width_type.
  • g (gain): The amount of boost (positive value) or cut (negative value) in decibels (dB) to apply to the target frequency.

Practical Examples

1. Basic Single-Band Adjustment

To boost a specific frequency (for example, boosting bass at 80 Hz by 6 dB using a bandwidth of 20 Hz), use the following command:

ffmpeg -i input.mp3 -af "equalizer=f=80:width_type=h:w=20:g=6" output.mp3

To cut a harsh frequency (for example, reducing a whistle at 4000 Hz by 8 dB with a Q-factor of 2.0), use:

ffmpeg -i input.mp3 -af "equalizer=f=4000:width_type=q:w=2.0:g=-8" output.mp3

2. Creating a Multi-Band Parametric Equalizer

To configure a true multi-band parametric equalizer, you can chain multiple equalizer filters together, separated by commas. Each filter in the chain acts as an independent band.

The following command applies a three-band parametric EQ to adjust low, mid, and high frequencies simultaneously:

ffmpeg -i input.wav -af "equalizer=f=100:width_type=h:w=50:g=4,equalizer=f=1000:width_type=q:w=1.5:g=-3,equalizer=f=8000:width_type=o:w=1:g=5" output.wav

In this multi-band example:

  • Band 1 (Bass): Boosts 100 Hz by 4 dB with a bandwidth of 50 Hz.
  • Band 2 (Mids): Cuts 1000 Hz by 3 dB with a Q-factor of 1.5.
  • Band 3 (Treble): Boosts 8000 Hz by 5 dB with a bandwidth of 1 octave.