How to Remove Audio Hiss with FFmpeg anlmdn Filter
Background hiss can ruin an otherwise perfect audio recording, but
FFmpeg offers a powerful, built-in solution called the
anlmdn (Audio Non-Local Means Denoising) filter. This guide
provides a straightforward tutorial on how to use the
anlmdn filter to clean up your audio tracks, explaining the
essential parameters and providing practical command-line examples to
achieve professional, noise-free results.
Understanding the anlmdn Filter
The anlmdn filter uses a non-local means algorithm to
reduce broadband noise, making it highly effective at removing constant
background hiss, computer fan noise, and system buzz from audio tracks.
Unlike simple noise gates, it analyzes the audio over time to
distinguish between actual content (like speech or music) and background
noise, preserving the original audio quality.
Basic Usage
To apply the default denoising settings to an audio file, use the following basic FFmpeg command:
ffmpeg -i input.mp3 -af anlmdn output.mp3This command takes your source file (input.mp3), applies
the anlmdn audio filter (-af), and outputs a
cleaner version (output.mp3).
Tuning the Filter Parameters
For optimal results, you will often need to adjust the filter’s
parameters. The anlmdn filter accepts several key
options:
s(strength): Controls the amount of denoising applied. The default value is0.00001. Increase this value for stronger noise reduction, though setting it too high can make the audio sound muffled or artificial. Typical effective values range from0.0001to0.005.p(patch duration): Sets the patch duration in seconds. The default is0.002(2 milliseconds).r(research duration): Sets the research duration in seconds. The default is0.015(15 milliseconds).om(output mode): Determines what the filter outputs.o(output): Outputs the denoised audio (default).i(input): Outputs the original, unmodified audio.n(noise): Outputs only the noise that is being removed. This is incredibly useful for testing to ensure you aren’t accidentally removing important parts of your main audio.
Practical Examples
1. Removing Moderate Background Hiss
For standard background hiss in a voice recording, a slightly higher strength value is usually required. Try this command:
ffmpeg -i input.wav -af "anlmdn=s=0.0005" output.wav2. Aggressive Denoising for Loud Hiss
If you are dealing with a very noisy recording, you can increase the strength further. Be sure to listen closely for any metallic or robotic digital artifacts in the output:
ffmpeg -i input.wav -af "anlmdn=s=0.002:p=0.004:r=0.02" output.wav3. Monitoring the Removed Noise
To verify that you are only removing hiss and not clipping your
actual audio, output only the noise profile using the om
parameter:
ffmpeg -i input.wav -af "anlmdn=s=0.0005:om=n" noise_only.wavListen to noise_only.wav. If you can clearly hear speech
or music in this file, your strength (s) parameter is set
too high, and you should lower it to avoid distorting your final
output.