FFmpeg Deband Filter Threshold Range and Direction
This article explains how to configure the deband filter
in FFmpeg to eliminate color banding artifacts in your videos. You will
learn how to adjust the threshold, range, and direction parameters to
effectively smooth out color gradients without sacrificing essential
image details.
The deband filter in FFmpeg is designed to reduce color
banding—a common compression artifact where smooth gradients of color
appear as distinct, blocky steps. To fine-tune this filter, you must
configure three primary parameters: threshold,
range, and direction.
1. Configuring Threshold
(threshold or thr)
The threshold parameter determines how sensitive the filter is when detecting banding. It defines the maximum difference in pixel values that will be considered part of a band and therefore smoothed out.
- Syntax:
threshold(applies to all planes) or individual plane thresholds likethr_y,thr_u, andthr_v(for luma and chroma planes). - Values: A float value ranging from
0.00003to0.5. The default is0.02. - How it works:
- Higher values make the filter more aggressive, which is useful for severe banding but can lead to a loss of fine textures (like skin pores or grain).
- Lower values preserve details but may fail to remove visible banding.
Example command for aggressive debanding:
ffmpeg -i input.mp4 -vf "deband=threshold=0.05" output.mp42. Configuring Range
(range or ran)
The range parameter defines the maximum distance (in pixels) the filter looks to find a neighboring pixel to compare and blend.
- Syntax:
rangeorr. - Values: An integer ranging from
1to64(or a dynamic formula). The default is16. - How it works:
- Larger ranges are ideal for wide, gradual gradients (like a clear blue sky).
- Smaller ranges are better suited for narrow gradients or smaller objects.
- Using a larger range increases computational overhead, which can slow down rendering.
Example command with an increased search range:
ffmpeg -i input.mp4 -vf "deband=range=24" output.mp43. Configuring Direction
(direction or dir)
The direction parameter controls the angle at which the filter searches for banding patterns. By shifting the search angle, the filter avoids creating artificial patterns during the smoothing process.
- Syntax:
directionord. - Values: An angle in radians, or
-1for a random direction. The default is-1. - How it works:
- Random direction (
-1) is highly recommended for most video content because changing the direction for every pixel prevents visible, recurring alignment artifacts. - Fixed directions (such as
0for horizontal, or1.5708for vertical) can be used if the banding is strictly oriented in a single direction.
- Random direction (
Example command using a fixed direction (e.g., approximately 45 degrees / 0.785 radians):
ffmpeg -i input.mp4 -vf "deband=direction=0.785" output.mp4Combining Parameters for Optimal Results
To get the best results, you should combine these settings. For a standard high-definition video with moderate banding, the following command offers a balanced configuration by increasing the threshold slightly and using a wider range while keeping the direction randomized:
ffmpeg -i input.mp4 -vf "deband=threshold=0.03:range=20:direction=-1" output.mp4