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:
1stst,2ndst,3rdst,4thst(Thresholds): These set the banding detection threshold for each video plane (Luma, Blue-difference, Red-difference, and Alpha). The values range from0.00003to0.5. Higher values apply stronger debanding but can blur fine details.range: The maximum distance in pixels to search for neighboring pixels to average. A larger range (typically between8and32) is useful for wide, gradual gradients.grain: Adds a small amount of random noise (grain) to the filtered areas. This is highly effective at masking any remaining banding and making the gradient look more natural.blur: A boolean option (trueorfalse) that decides whether to blur the neighboring pixels. Enabling this (which is the default) results in smoother transitions.
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.mp42. 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.mp4In 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.mp4Setting 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
Output to 10-bit Video: Color banding is often caused by the limitations of 8-bit color depth. Even if your input file is 8-bit, encoding your output to 10-bit (using
yuv420p10le) after applying thedebandfilter will significantly reduce the chance of banding reoccurring.ffmpeg -i input.mp4 -vf "deband" -c:v libx264 -pix_fmt yuv420p10le -crf 18 output.mp4Avoid Over-Smoothing: Setting the thresholds too high will destroy fine textures, such as facial details or clothing fibers. Always test your command on a short segment of your video first using
-ssand-tto ensure you strike the right balance between smooth gradients and sharp details.