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.

  • green (or g): Targets green color spill (default).
  • blue (or b): Targets blue color spill.

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:

  • red: Adjusts the red color scale factor. (Range: -2.0 to 2.0, Default: 0.0)
  • green: Adjusts the green color scale factor. (Range: -2.0 to 2.0, Default: -0.5 for green spill)
  • blue: Adjusts the blue color scale factor. (Range: -2.0 to 2.0, Default: -0.5 for blue spill)
  • brightness: Scale factor for the overall brightness of the despilled area. (Range: -10.0 to 10.0, Default: 0.0)

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.

  • mix: Controls the strength of the despill effect by blending the processed frame with the original frame. A value of 1.0 applies the despill completely, while 0.0 applies no effect. (Range: 0.0 to 1.0, Default: 0.5)
  • expand: Expands the despill map to affect pixels further away from the key color edges. (Range: 0.0 to 1.0, Default: 0.0)

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