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.mp3

In 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:

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.wav

Heavy 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.wav

Checking 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