How to Set Denoising Strength in FFmpeg anlmdn
This article explains how to configure the denoising strength of the
anlmdn (Audio Non-Local Means Denoising) filter in FFmpeg.
You will learn about the specific parameters that control noise
reduction intensity, how these values affect your audio output, and how
to apply them using practical command-line examples.
The anlmdn filter reduces broadband noise in audio files
using a non-local means algorithm. The primary parameter used to
configure the denoising strength is the
strength (or
s) option.
The Strength Parameter
(strength or s)
The strength parameter defines the factor applied to the
filtering threshold. It directly controls how aggressively the filter
removes noise.
- Default Value:
0.00001 - Allowed Range:
0.00001to10000.0 - Behavior: Lower values result in milder noise reduction, preserving more of the original audio’s characteristics. Higher values result in stronger noise reduction but can introduce computational artifacts, phasing, or “watery” sounding audio if set too high.
How to Apply the Filter
To adjust the denoising strength, pass the s parameter
to the anlmdn audio filter flag (-af).
Example 1: Gentle Denoising
For audio with light background hiss, a low strength value is recommended to keep the primary audio clean and natural.
ffmpeg -i input.mp3 -af "anlmdn=s=0.00005" output.mp3Example 2: Moderate Denoising
This setting works well for standard voice recordings with noticeable background hum.
ffmpeg -i input.wav -af "anlmdn=s=0.0005" output.wavExample 3: Heavy Denoising
For highly degraded audio with loud background noise, you can increase the strength further. Note that this may muffle high frequencies.
ffmpeg -i input.m4a -af "anlmdn=s=0.005" output.m4aSupporting Parameters
While strength is the main setting for noise reduction
intensity, you can fine-tune the filter’s behavior using these
complementary parameters:
patch_size(orp): Sets the patch duration in seconds (default is0.002). A larger patch size can improve noise estimation at the cost of higher CPU usage.research_size(orr): Sets the research band duration in seconds (default is0.01). This controls the window size where the algorithm looks for similar audio patches.smoothness(orm): Controls the dampening factor for the filtering lookup table (default is1.0). Adjusting this can help reduce artificial musical noise introduced by high strength settings.
Here is an example combining these settings for optimized voice denoising:
ffmpeg -i input.wav -af "anlmdn=s=0.0008:p=0.004:r=0.02" output.wav