How to Use FFmpeg removegrain Filter for Denoising

This guide explains how to use the removegrain filter in FFmpeg to achieve high-efficiency spatial denoising and image smoothing. You will learn how the filter works, how to configure its various mode options, and see practical command-line examples to clean up noisy video streams quickly without sacrificing system performance.

What is the removegrain Filter?

The removegrain filter is a highly optimized spatial denoising filter in FFmpeg. Unlike temporal denoisers that analyze multiple video frames over time, removegrain operates entirely within each individual frame (spatially). It compares each pixel with its surrounding eight neighbors to identify and eliminate noise, compression artifacts, and rogue pixels. Because it relies on fast, hardware-optimized assembly code, it is one of the fastest denoising filters available in FFmpeg, making it ideal for real-time encoding and low-power systems.

Understanding the Syntax and Modes

The basic syntax for the removegrain filter in FFmpeg is:

-vf removegrain=m0=X:m1=Y:m2=Z:m3=W

Alternatively, you can use the shorthand version:

-vf removegrain=X:Y:Z:W

If you specify only one mode, it applies to the first plane, and subsequent planes will copy the setting of the previous plane.

The filter supports modes from 0 to 24. Here are the most useful modes for denoising and smoothing:

Practical Examples

1. Basic Gentle Denoising

To apply a light, safe denoiser to all video planes (Luma and Chroma) to clean up compression noise while retaining sharp edges, use Mode 2:

ffmpeg -i input.mp4 -vf removegrain=m0=2:m1=2:m2=2 -c:a copy output.mp4

2. High-Efficiency Spatial Smoothing

If your video has heavy grain or blocky compression artifacts, you can use Mode 11 to smooth the image:

ffmpeg -i input.mp4 -vf removegrain=m0=11:m1=11:m2=11 -c:v libx264 -crf 18 output.mp4

3. Targeted Luma and Chroma Filtering

Because human eyes are more sensitive to details in brightness (Luma) than in color (Chroma), you can apply a stronger smoothing filter to the Luma plane and a gentler denoiser to the Chroma planes:

ffmpeg -i input.mp4 -vf removegrain=m0=11:m1=2:m2=2 -c:a copy output.mp4

In this command: * m0=11 applies a spatial blur to the Luma plane to smooth out grain. * m1=2 and m2=2 apply a gentle edge-preserving denoiser to the Chroma planes to prevent color bleeding.