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=val3

Alternatively, you can use positional shorthand:

removegrain=val0:val1:val2:val3

The Inheritance Rule

If you do not specify a mode for a plane, it inherits the value of the previously specified plane.

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:

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

Example 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.mp4

In 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