How to Use FFmpeg Bandreject Filter to Remove Frequencies
This article explains how to use the bandreject audio
filter in FFmpeg to isolate and eliminate a specific range of unwanted
frequencies from an audio file. You will learn the core syntax, the key
parameters (such as center frequency and bandwidth), and practical
command-line examples to effectively remove hums, buzzes, or specific
interference from your audio tracks.
The bandreject filter in FFmpeg is an audio filter that
attenuates a narrow band of frequencies around a specified center
frequency, allowing all other frequencies outside of this band to pass
through. This is particularly useful for notch filtering, which targets
precise noises like a 50 Hz or 60 Hz electrical hum.
The Basic Syntax
To apply the bandreject filter, use the -af
(audio filter) flag in your FFmpeg command. The basic structure of the
filter is:
ffmpeg -i input.mp4 -af "bandreject=f=FREQUENCY:width_type=TYPE:w=WIDTH" output.mp4Key Parameters
The bandreject filter relies on three main parameters to
define the frequency range you want to eliminate:
f(frequency): Sets the center frequency in Hz. This is the exact middle of the range you want to remove. The default is 3000 Hz.width_type(t): Defines how the filter measures the width of the band. Common options include:h(Hz): Specifies the width directly in Hertz (default).q(Q-factor): Specifies the width as a Q-factor. A higher Q-factor results in a narrower, sharper cut.o(octaves): Specifies the width in octaves.
w(width): Sets the actual width of the band using the unit specified inwidth_type. The default is 500 Hz.
Practical Examples
Example 1: Removing a 1000 Hz tone with a 200 Hz width If you have a constant whistle at 1000 Hz and want to mute the range from 900 Hz to 1100 Hz, use the following command:
ffmpeg -i input.wav -af "bandreject=f=1000:width_type=h:w=200" output.wavExample 2: Precision filtering using Q-factor For a highly surgical cut that removes an exact frequency while minimizing damage to surrounding audio, use a high Q-factor. This command removes a 60 Hz hum with a Q-factor of 2.0:
ffmpeg -i input.mp3 -af "bandreject=f=60:width_type=q:w=2" output.mp3Combining Multiple Filters
If you need to remove multiple distinct frequency ranges, you can
chain multiple bandreject filters together, separated by
commas:
ffmpeg -i input.wav -af "bandreject=f=120:w=10,bandreject=f=240:w=15" output.wavUsing these configurations, you can easily clean up your audio tracks by targeting and suppressing problematic frequencies using FFmpeg.