FFmpeg Removegrain Luma and Chroma Mode Guide
This article provides a direct guide on how to configure the luma and
chroma plane modes using the FFmpeg removegrain filter. It
covers the filter’s syntax, details how the filter’s parameters map to
different video planes, explains the critical parameter inheritance
rules, and provides practical command-line examples to help you optimize
your video denoising workflow.
Understanding Video Planes in FFmpeg
The removegrain filter operates on the individual color
planes of a video. In typical YUV color spaces, these planes are divided
as follows: * Plane 0 (Y): Luma (brightness) *
Plane 1 (U): Chroma (blue-difference color relation) *
Plane 2 (V): Chroma (red-difference color relation) *
Plane 3 (A): Alpha (transparency, if present)
To control the denoising behavior of these planes, the filter
utilizes four mode parameters: m0, m1,
m2, and m3.
The Syntax and Parameter Inheritance Rule
The basic syntax for the filter is:
removegrain=m0=val0:m1=val1:m2=val2:m3=val3Alternatively, you can use positional shorthand:
removegrain=val0:val1:val2:val3The Inheritance Rule
If you do not specify a mode for a plane, it inherits the value of the previously specified plane.
- If you only specify
m0=2, thenm1,m2, andm3will all inherit2. - If no modes are specified at all, they default to
0(pass-through).
To prevent inheritance and process planes differently, you must explicitly reset the subsequent planes.
Common Mode Values
The removegrain filter supports modes from
0 to 24. Here are the most commonly used
modes:
- 0: Pass-through (the plane is left completely untouched).
- 1: Simple clipping (safest mode for very light denoising).
- 2 to 4: Progressive clipping modes using 3x3 neighborhoods. Mode 4 is a strong, median-like filter.
- 17: A standard spatial blur.
- 20: A stronger spatial blur.
Practical Configuration Examples
Example 1: Apply Denoising to Luma Only
To denoise the luma plane (using mode 2) while leaving the chroma
planes completely untouched, you must set m0 to
2 and explicitly reset m1 to 0 so
the remaining planes inherit 0:
ffmpeg -i input.mp4 -vf "removegrain=m0=2:m1=0" output.mp4Example 2: Denoise Luma and Chroma Differently
Chroma noise is often blockier and requires stronger filtering than
luma. To apply a mild denoising mode (2) to luma, and a
stronger blurring mode (20) to both chroma planes:
ffmpeg -i input.mp4 -vf "removegrain=m0=2:m1=20" output.mp4In this case, m0 is 2. m1
is set to 20, and m2 automatically inherits
20 from m1.
Example 3: Shorthand Configuration
You can achieve the same result as Example 2 using positional arguments without the parameter names:
ffmpeg -i input.mp4 -vf "removegrain=2:20" output.mp4