FFmpeg Low-Pass Filter Guide for Linux
Applying a low-pass filter to an audio stream using FFmpeg on Linux
allows you to attenuate high-frequency sounds above a specified cutoff
frequency while letting lower frequencies pass through. This article
provides a straightforward guide on how to use FFmpeg’s built-in audio
filtering tools, specifically the lowpass filter, detailing
the essential commands for processing audio files and live streams,
adjusting filter steepness, and optimizing your audio output directly
from the Linux terminal.
Understanding the FFmpeg Low-Pass Filter
The primary tool for this task is the -af (audio filter)
flag combined with the lowpass filter plugin. A low-pass
filter is incredibly useful for removing high-pitched hiss, background
noise, or preparing audio for subwoofers.
The two most important parameters you will configure are:
- f: The cutoff frequency in Hertz (Hz). Frequencies above this limit will be attenuated.
- poles: The number of poles (usually 1 or 2). A higher number creates a steeper, more aggressive cutoff slope. The default value is 2.
Basic Command Syntax
To apply a simple low-pass filter to an audio file, use the following command structure in your Linux terminal:
ffmpeg -i input.mp3 -af "lowpass=f=3000" output.mp3In this example, f=3000 sets the cutoff frequency to
3000 Hz (3 kHz). Everything above this frequency will be significantly
quieted down.
Advanced Filtering Options
Adjusting Filter Steepness with Poles
If you want a more gradual reduction of high frequencies, you can drop the poles down to 1. For the sharpest built-in cutoff, stick to the default of 2:
ffmpeg -i input.wav -af "lowpass=f=1500:poles=1" output.wavFiltering Live Audio Streams
If you are dealing with a live audio stream (such as an RTMP stream or a pulse audio input device on Linux) and want to output it to a new stream or file, the syntax remains similar. You just need to specify the real-time input format:
ffmpeg -i rtmp://localhost/live/stream -af "lowpass=f=4000" -c:a aac output.mp4Combining Low-Pass with Volume Normalization
Filters can sometimes lower the perceived overall volume of your stream. You can chain the low-pass filter with a volume filter using a comma:
ffmpeg -i input.ogg -af "lowpass=f=2500,volume=1.5" output.oggVerifying the Output
To ensure your filter has been applied correctly without fully
exporting massive files, you can test the audio playback live in your
Linux terminal using ffplay, which natively accepts the
same filter arguments:
ffplay -i input.mp3 -af "lowpass=f=2000"