How to Denoise Video with FFmpeg nlmeans Filter

This guide explains how to use the Non-Local Means (nlmeans) filter in FFmpeg to effectively remove noise and grain from your videos. You will learn the basic command structure, the key parameters that control denoising strength, and practical examples to help you achieve clean, high-quality video output.

Understanding the nlmeans Filter

The nlmeans filter is one of the most powerful denoising algorithms available in FFmpeg. Unlike simple pixel-averaging filters, Non-Local Means looks for similar patches of pixels across the entire frame to average out noise. While this results in excellent detail preservation, it is computationally expensive and slow to process.

Basic Syntax and Parameters

To use the filter, you apply it via the -vf (video filter) flag. The basic syntax is:

ffmpeg -i input.mp4 -vf nlmeans=s=1.0:p=7:r=15 output.mp4

Here are the primary parameters you can adjust to fine-tune the denoising process:

Practical Examples

1. Light Denoising (Fastest Processing)

For videos with minimal noise where you want to preserve maximum detail and speed up rendering, use lower strength and smaller search windows.

ffmpeg -i input.mp4 -vf nlmeans=s=1.0:p=5:r=9 output.mp4

2. Moderate Denoising (Balanced/Default)

This is the recommended starting point for standard noisy footage. It offers a good balance between noise reduction and detail preservation.

ffmpeg -i input.mp4 -vf nlmeans=s=1.5:p=7:r=15 output.mp4

3. Heavy Denoising (High Quality, Very Slow)

Use this option for extremely grainy or low-light footage. Note that this command will take significantly longer to render.

ffmpeg -i input.mp4 -vf nlmeans=s=3.0:p=9:r=21 output.mp4

Performance Tips

Because nlmeans is highly CPU-intensive, you can combine it with hardware acceleration or multi-threading options. Ensure your FFmpeg build is compiled with threading support to allow nlmeans to utilize all available CPU cores automatically. If your encoding speed is too slow, consider reducing the search window (r) to 11 or 9.