Load Custom EQ Text Files in FFmpeg Firequalizer

This guide explains how to apply custom equalization curves from a text file using FFmpeg’s firequalizer audio filter. Because firequalizer lacks a built-in parameter for directly importing curve files, custom equalization profiles must be written as mathematical expressions based on frequency and injected into the filter via shell substitution. The following sections outline how to format your text file and pass it into FFmpeg across different operating systems.


1. Formatting the Equalization Text File

The firequalizer filter evaluates frequency responses using the gain_entry option, where gain is expressed in decibels (dB) as a function of frequency f (in Hertz).

To supply your values via a text file, create a file named eq.txt containing a valid FFmpeg expression.

Option A: Stepped Bands (Piecewise Constant)

For simple cutoff points where specific frequency ranges receive a fixed dB boost or cut, format eq.txt using nested if() statements:

if(lte(f,100), 4, if(lte(f,500), 2, if(lte(f,2000), 0, if(lte(f,8000), -2, -4))))

In this example:

  • Frequencies up to 100 Hz receive a +4 dB boost.
  • Frequencies between 100 Hz and 500 Hz receive +2 dB.
  • Frequencies between 500 Hz and 2000 Hz receive 0 dB.
  • Frequencies between 2000 Hz and 8000 Hz receive -2 dB.
  • Frequencies above 8000 Hz receive -4 dB.

Option B: Linear Interpolation Between Points

For smoother transitions between frequency points, define linear interpolation between target frequencies:

if(lte(f,100), 3, if(lte(f,1000), 3 + (f-100)*(-6)/(1000-100), -3))

2. Executing the FFmpeg Command

Since FFmpeg reads the curve through the command-line argument, use your environment's shell substitution to load the contents of eq.txt into the filter graph.

Linux and macOS (Bash / Zsh)

Use command substitution $(...) and strip newline characters to ensure the filter string parses without errors:

ffmpeg -i input.mp3 -af "firequalizer=gain_entry='$(tr -d '\n' < eq.txt)'" output.mp3

Windows (PowerShell)

Use PowerShell's Get-Content with the -Raw flag to read the file as a continuous string:

ffmpeg -i input.mp3 -af "firequalizer=gain_entry='$(Get-Content eq.txt -Raw)'" output.mp3

Windows (Command Prompt)

Read the file into an environment variable before invoking FFmpeg:

set /p EQ_EXPR=<eq.txt
ffmpeg -i input.mp3 -af "firequalizer=gain_entry='%EQ_EXPR%'" output.mp3

To fine-tune performance and accuracy when applying curves via firequalizer, consider adding these complementary options inside the -af flag:

  • accuracy: Sets the frequency resolution in Hertz (default is 5). Lower values produce higher precision at the expense of higher CPU usage:

    firequalizer=gain_entry='$(tr -d '\n' < eq.txt)':accuracy=1
  • scale: Changes the interpolation scale. Options include lin (linear, default) or log (logarithmic). A logarithmic scale often mirrors human hearing more accurately:

    firequalizer=gain_entry='$(tr -d '\n' < eq.txt)':scale=log
  • zero_phase: Set to 1 to enable zero-phase filtering, which prevents phase distortion across frequencies.