Configure FFmpeg Despill Spill-Type and Color Scale

This article explains how to use and configure the despill video filter in FFmpeg to remove color bleeding caused by green or blue screens. You will learn how to define the target spill-type, adjust color scaling parameters, control the blending mix, and implement these configurations using practical command-line examples.

The FFmpeg Despill Filter

When shooting video against a green or blue screen, light reflecting off the background often creates a colored halo or “spill” around the subject. The FFmpeg despill filter detects and neutralizes these unwanted color casts.

To configure the filter, you must define the target spill color and fine-tune the color scale coefficients to balance the image.


Configuring the Spill-Type

The type parameter determines which background color the filter targets.

Example Syntax:

To target a blue screen spill:

ffmpeg -i input.mp4 -vf "despill=type=blue" output.mp4

Configuring Color Scales and Coefficients

The despill filter allows you to scale individual RGB color channels to restore natural tones to the spill areas. Adjusting these values helps prevent the subject from looking too gray or discolored after the background spill is removed.

The primary color scale parameters include:

Example: Custom Color Scaling for Green Screen

If removing a green screen leaves your subject’s edges looking too magenta, you can scale up the red channel and scale down the green channel:

ffmpeg -i input.mp4 -vf "despill=type=green:red=0.2:green=-0.6" output.mp4

Adjusting Spill Intensity and Expansion

To fine-tune how aggressively the despill filter is applied, use the mix and expand parameters.

Example: Heavy Spill Removal

For strong color spill that covers a wider area of your subject, increase the mix intensity and slightly expand the filter’s reach:

ffmpeg -i input.mp4 -vf "despill=type=green:mix=0.8:expand=0.2" output.mp4