How to Use FFmpeg Deband Filter to Remove Color Banding

Color banding is a common visual artifact that occurs when smooth color gradients (such as skies, shadows, or underwater scenes) display distinct, blocky steps of color instead of a seamless transition. This article explains how to use the FFmpeg deband filter to eliminate these artifacts, covering the essential parameters like thresholds, range, and grain, along with practical command-line examples to help you achieve clean, smooth video output.

The FFmpeg deband Filter Parameters

The deband filter works by detecting gradients and applying a smoothing algorithm to blend the steps together. To customize the filter, you can adjust several key parameters:


Practical Command Examples

1. Basic Debanding (Default Settings)

If your video has light banding, FFmpeg’s default deband settings are often enough to fix the issue. Use the following command:

ffmpeg -i input.mp4 -vf "deband" -c:v libx264 -crf 18 -c:a copy output.mp4

2. Moderate Debanding with Custom Thresholds and Range

For more noticeable banding, you can manually increase the threshold for the luma and chroma channels, and expand the search range:

ffmpeg -i input.mp4 -vf "deband=1stst=0.03:2ndst=0.03:range=20" -c:v libx264 -crf 18 -c:a copy output.mp4

In this command, the thresholds for the first two planes are set to 0.03 and the pixel search range is extended to 20.

3. Aggressive Debanding with Dynamic Grain

For severe banding (often found in heavily compressed anime or dark scenes), you can apply stronger filtering and add dynamic grain to mask the flat areas:

ffmpeg -i input.mp4 -vf "deband=1stst=0.05:2ndst=0.05:range=24:grain=3.0" -c:v libx264 -crf 18 -c:a copy output.mp4

Setting grain=3.0 introduces a subtle dither effect that tricks the eye into seeing a smooth gradient, preventing the video from looking overly washed out.


Best Practices for Output Quality