How to Use FFmpeg Bass and Treble Filters
Adjusting the equalization of an audio file is a common task that can
be easily achieved using FFmpeg’s built-in command-line tools. This
article provides a quick and straightforward guide on how to use the
bass and treble audio filters in FFmpeg to
boost or cut low and high frequencies, complete with practical command
examples.
Understanding the Bass and Treble Filters
FFmpeg provides two specific audio filters, bass and
treble, which act as shelving equalizers. They allow you to
boost (increase volume) or cut (decrease volume) frequencies below or
above a specific limit.
Both filters accept three primary parameters: * g (gain): The amount of boost or cut in decibels (dB). Positive numbers boost the frequency, while negative numbers cut it. * f (frequency): The central or shelf frequency in Hz. * w (width): The filter’s bandwidth or slope (often left at its default value of 0.5).
How to Use the Bass Filter
The bass filter targets low-frequency sounds (typically
below 300 Hz). By default, it operates at a center frequency of 100
Hz.
To boost the bass by 8 dB at the default frequency of 100 Hz, use the following command:
ffmpeg -i input.mp3 -af "bass=g=8" output.mp3To cut the bass by 5 dB at a custom frequency of 150 Hz to reduce muddiness, run:
ffmpeg -i input.mp3 -af "bass=g=-5:f=150" output.mp3How to Use the Treble Filter
The treble filter targets high-frequency sounds. By
default, it operates at a center frequency of 3000 Hz.
To boost the treble by 6 dB to add brightness to a track, use:
ffmpeg -i input.mp3 -af "treble=g=6" output.mp3To cut harsh high frequencies by 10 dB at a custom frequency of 8000 Hz (8 kHz), use:
ffmpeg -i input.mp3 -af "treble=g=-10:f=8000" output.mp3Combining Bass and Treble Adjustments
You can apply both filters simultaneously in a single command by
chaining them together with a comma inside the audio filter
(-af) argument.
To boost both the bass (by 6 dB at 80 Hz) and the treble (by 5 dB at 10,000 Hz) for a classic “smile” EQ curve, run:
ffmpeg -i input.mp3 -af "bass=g=6:f=80,treble=g=5:f=10000" output.mp3