How to Use the FFmpeg Bandreject Filter

This article explains how to use the bandreject audio filter in FFmpeg to remove a specific range of frequencies from an audio file. You will learn the basic syntax of the filter, understand its key parameters like center frequency and bandwidth, and see practical command-line examples to help you clean up your audio tracks.

Understanding the Bandreject Filter

The bandreject filter (also known as a band-stop or notch filter) attenuates a specific band of frequencies around a chosen center frequency. Frequencies outside of this specified band are allowed to pass through relatively unaffected. This is highly useful for removing unwanted constant background noises, such as a 60 Hz electrical hum or a high-pitched whistle.

Basic Syntax

The basic syntax for applying the bandreject filter in FFmpeg is:

ffmpeg -i input.mp3 -af "bandreject=f=FREQUENCY:w=WIDTH" output.mp3

Key Parameters

The bandreject filter accepts several parameters to customize how the audio is processed:


Practical Examples

Example 1: Removing a 60 Hz Hum

Ground loop issues often cause a low-frequency hum at 60 Hz (or 50 Hz depending on your region). To remove a 60 Hz hum with a narrow band of 10 Hz, use the following command:

ffmpeg -i input.wav -af "bandreject=f=60:w=10" output.wav

Example 2: Using Q-Factor for Precision

If you prefer to define the filter’s sharpness using a Q-factor instead of raw Hertz, change the width_type (t) to q. A higher Q-factor results in a narrower, more precise notch.

ffmpeg -i input.mp3 -af "bandreject=f=1000:t=q:w=2.0" output.mp3

In this command, the filter targets 1000 Hz with a Q-factor of 2.0.

Example 3: Applying Multiple Filters

If your audio contains multiple unwanted frequencies, you can chain multiple bandreject filters together, separated by commas.

ffmpeg -i input.wav -af "bandreject=f=120:w=15,bandreject=f=1000:w=100" output.wav

This command simultaneously targets a hum at 120 Hz and a broader range of noise around 1000 Hz.