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.

Example command for aggressive debanding:

ffmpeg -i input.mp4 -vf "deband=threshold=0.05" output.mp4

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

Example command with an increased search range:

ffmpeg -i input.mp4 -vf "deband=range=24" output.mp4

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

Example command using a fixed direction (e.g., approximately 45 degrees / 0.785 radians):

ffmpeg -i input.mp4 -vf "deband=direction=0.785" output.mp4

Combining 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