How to Use the FFmpeg Bandpass Filter
This article provides a quick and practical guide on how to use the
bandpass audio filter in FFmpeg. You will learn the basic
syntax, key parameters such as center frequency and bandwidth, and see
concrete command-line examples to isolate specific frequency ranges in
your audio files.
Understanding the Bandpass Filter
A bandpass filter allows frequencies within a certain range to pass through while attenuating (quieting) frequencies below and above this range. This is highly useful for isolating specific sounds, such as human speech, or removing low-frequency rumbles and high-frequency hisses simultaneously.
Filter Parameters
The bandpass filter in FFmpeg uses three primary
parameters to control the audio output:
frequency(orf): The center frequency of the band in Hz. The default is3000Hz.width_type(ort): The unit used to define the bandwidth. Options include:h: Hz (default)q: Q-factor (higher Q means a narrower, sharper band)o: Octaves
width(orw): The width of the band. The default is200Hz.
Basic Syntax
The basic syntax for applying the bandpass filter using the
-af (audio filter) flag is:
ffmpeg -i input.wav -af "bandpass=f=CENTER_FREQUENCY:w=BANDWIDTH" output.wavPractical Examples
1. Isolate a Specific Frequency (Standard Hz Width)
To isolate a frequency range centered at 1000 Hz with a width of 200 Hz (allowing frequencies roughly between 900 Hz and 1100 Hz to pass), use the following command:
ffmpeg -i input.mp3 -af "bandpass=f=1000:w=200" output.mp32. Isolate Human Speech
Human speech generally falls between 300 Hz and 3400 Hz. To target this range, you can set the center frequency to 1850 Hz and the width to 3100 Hz:
ffmpeg -i interview.mp4 -af "bandpass=f=1850:w=3100" cleared_speech.mp43. Using Q-Factor for a Narrow Band
If you want a very sharp, narrow band around 2000 Hz, you can define the width using the Q-factor. A higher Q-factor results in a narrower filter:
ffmpeg -i input.wav -af "bandpass=f=2000:t=q:w=2.0" output.wav4. Combining Bandpass with Other Filters
You can chain the bandpass filter with other audio filters, such as volume adjustment, by separating them with a comma:
ffmpeg -i input.wav -af "bandpass=f=1500:w=500,volume=1.5" output.wav