Boost High Frequencies with FFmpeg Treble Filter
This article provides a straightforward guide on how to use the
treble filter in FFmpeg to boost high-frequency audio. You
will learn the basic command syntax, key parameters like gain and
frequency, and practical examples to enhance the clarity and brightness
of your audio files.
The treble filter in FFmpeg is a shelving filter,
meaning it boosts or attenuates frequencies above a specified cutoff
point.
Basic Syntax
To apply the treble filter, use the audio filter flag
(-af) followed by the filter name and its parameters:
ffmpeg -i input.mp3 -af "treble=g=GAIN" output.mp3Key Parameters
The treble filter accepts several parameters to
customize how the high frequencies are altered:
g(gain): The amount of boost or attenuation in dB. To boost the treble, use a positive value (e.g.,g=6for a 6 dB boost). To reduce treble, use a negative value (e.g.,g=-6). The default is 0.f(frequency): The center frequency in Hz where the filter begins to apply. The default frequency is 3000 Hz.w(width): The bandwidth of the filter, which determines how steep the transition is. It can be specified in octaves, Q-factor, or Hz. The default is 0.5.
Practical Examples
1. Basic Treble Boost
To apply a standard 6 dB boost to frequencies above the default 3000 Hz, use the following command:
ffmpeg -i input.wav -af "treble=g=6" output.wav2. Boosting Specific High Frequencies
If you want to target higher frequencies, such as 8000 Hz (8 kHz),
and boost them by 8 dB, define both the gain (g) and
frequency (f) parameters:
ffmpeg -i input.wav -af "treble=g=8:f=8000" output.wav3. Adjusting Filter Width
To make the transition into the treble boost gentler or sharper, you
can adjust the width (w) parameter. A wider shelf (higher
value) creates a smoother transition:
ffmpeg -i input.wav -af "treble=g=5:f=5000:w=0.7" output.wav