How to Denoise Audio with FFmpeg ANLMDN Filter
This article provides a practical guide on how to use the
anlmdn (Audio Non-Local Means Denoising) filter in FFmpeg
to remove unwanted background noise from your audio tracks. You will
learn the basic command structure, the key parameters available for
fine-tuning, and practical examples to help you achieve clean,
professional-sounding audio.
The anlmdn filter applies a non-local means algorithm to
audio data. Unlike traditional spectral subtraction filters, the
non-local means approach looks for similar patterns across the entire
audio track to distinguish between actual signal and random background
noise. This makes it highly effective at removing constant hiss, hums,
and system noise while preserving the original clarity of voices or
instruments.
Basic Command Syntax
The simplest way to apply the anlmdn filter with its
default settings is by using the following command:
ffmpeg -i input.mp3 -af anlmdn output.mp3In this command, -af specifies that an audio filter is
being applied, followed by the name of the filter,
anlmdn.
Adjusting the Parameters
To get the best results, you will often need to customize the
filter’s parameters. The anlmdn filter accepts several
options:
strength(ors): Controls the amount of denoising applied. The default value is0.00001. Increasing this value removes more noise but can introduce “watery” artifacts if set too high.patch(orp): Sets the patch duration in milliseconds. The default is0.002(2 ms). This defines the size of the audio blocks being compared.research(orr): Sets the research band duration in milliseconds. The default is0.006(6 ms). This defines the search window size for finding similar audio patterns.omax(oro): Sets the output mode.0outputs the denoised signal (default),1outputs only the noise that was removed, and2outputs a mix of both.
Practical Examples
Moderate Denoising for Voice Recordings For standard voice recordings with moderate background hiss, slightly increasing the denoising strength while keeping the patch sizes default works well:
ffmpeg -i input.wav -af anlmdn=s=0.00005 output.wavHeavy Denoising for High-Noise Environments If your audio has a high level of background noise, you can increase the strength further and expand the research duration to allow the algorithm to analyze larger sections of the audio:
ffmpeg -i input.wav -af anlmdn=s=0.0005:p=0.004:r=0.012 output.wavChecking the Removed Noise To listen to exactly what
the filter is removing from your audio, you can set the output mode to
1 (noise only). This is useful for ensuring you are not
accidentally filtering out parts of the actual voice or music:
ffmpeg -i input.wav -af anlmdn=o=1 noise_only.wav