How to Disable libmp3lame Low-Pass Filter
This article explains how to manually override or completely disable
the internal low-pass filter in the libmp3lame MP3 encoder.
While LAME automatically applies a low-pass filter to optimize
compression and audio quality at various bitrates, advanced users can
bypass these settings using specific command-line flags in the LAME CLI,
arguments in FFmpeg, or directly through the C API.
Understanding LAME’s Default Low-Pass Filter
By default, libmp3lame applies a low-pass filter to
remove high-frequency sounds (typically above 16 kHz to 20 kHz,
depending on the target bitrate). Removing these hard-to-hear
frequencies allows the encoder to allocate more data to the lower, more
audible frequency spectrum, resulting in a subjectively better-sounding
compression. However, for high-bitrate encodes (like 320 kbps) or
archival purposes, you may want to preserve the full frequency
range.
Method 1: Using the LAME Command-Line Interface (CLI)
If you are using the standalone LAME compiler, you can control the
low-pass filter using the --lowpass option.
To disable the low-pass filter entirely: Use a value of
-1. This instructs the encoder not to apply any low-pass filtering.lame --lowpass -1 input.wav output.mp3To manually override the low-pass frequency: Specify the target frequency in kilohertz (kHz). For example, to set the cutoff frequency to 20 kHz:
lame --lowpass 20 input.wav output.mp3
Method 2: Using FFmpeg
When using FFmpeg with the libmp3lame library, the
low-pass filter is controlled via the -cutoff option.
FFmpeg expects this value in Hertz (Hz).
To manually override the cutoff frequency: To force a high cutoff, such as 20 kHz, pass
-cutoff 20000in your command:ffmpeg -i input.wav -c:a libmp3lame -b:a 320k -cutoff 20000 output.mp3To disable the low-pass filter: Set the cutoff value to
-1. This bypasses LAME’s internal low-pass filter algorithms:ffmpeg -i input.wav -c:a libmp3lame -b:a 320k -cutoff -1 output.mp3
Method 3: Using the C API (for Developers)
If you are integrating libmp3lame into your own software
application, you can control the low-pass filter using the LAME API
functions defined in lame.h.
To disable the filter: Call the
lame_set_lowpassfreqfunction and pass-1as the frequency parameter before callinglame_init_params.lame_set_lowpassfreq(gfp, -1);To set a specific cutoff frequency: Pass the desired frequency in Hertz. For example, to set a 19.5 kHz cutoff:
lame_set_lowpassfreq(gfp, 19500);