Remove Green Screen Spill in FFmpeg with Despill

This guide provides a practical overview of using FFmpeg's native despill video filter to eliminate unwanted green or blue light reflections from actors filmed against chroma key backdrops. You will learn the fundamental syntax of the filter, its primary configuration parameters, and how to integrate it into your video processing workflows to preserve natural skin tones and edges.

Understanding the Despill Filter

When shooting against a chroma key backdrop, light reflects off the colored wall onto the subject's skin, hair, and clothing. The despill filter detects these unwanted green or blue tints and neutralizes them by blending the spilled color with adjacent color channels.

Core Parameters

The despill filter accepts several parameters to fine-tune the color suppression:

  • type: The color component to target. Acceptable values are green (default) or blue.
  • mix: Sets the strength of the spill removal, ranging from 0.0 to 1.0. The default is 0.5. Higher values eliminate more color but can introduce discoloration.
  • expand: Controls the spill expansion factor, ranging from 0.0 to 1.0. Default is 0.0. Increasing this expands the spill suppression further into edge pixels.
  • red / green / blue: Adjusts the scale coefficient for specific color channels (ranging from -100 to 100).

Basic Green Screen Spill Removal

To apply spill suppression directly to a raw or keyed green screen clip:

ffmpeg -i input.mp4 -vf "despill=type=green:mix=0.5" -c:a copy output.mp4

This replaces green contamination with an average balance of red and blue channels, neutralizing the green reflection into a neutral tone.

Fine-Tuning Spill Removal

If the default settings leave green fringing in thin hair strands or cause the subject's skin to look unnaturally magenta, adjust the mix and expand values:

ffmpeg -i input.mp4 -vf "despill=type=green:mix=0.7:expand=0.1" -c:a copy output.mp4
  • Increase mix if green fringes remain around the edges.
  • Lower mix toward 0.3 if edges appear too purple or gray.
  • Increase expand if the spill extends deep into semi-transparent elements like flyaway hair or translucent fabrics.

Removing Blue Spill

If working with a blue screen instead of green, switch the type parameter:

ffmpeg -i input.mp4 -vf "despill=type=blue:mix=0.6" -c:a copy output.mp4

Full Chroma Key and Despill Composite Pipeline

In a standard workflow, the despill filter is placed immediately after the chroma key operation inside -filter_complex:

ffmpeg -i foreground.mp4 -i background.jpg -filter_complex \
"[0:v]chromakey=0x00FF00:0.15:0.05,despill=type=green:mix=0.5[keyed]; \
 [1:v][keyed]overlay=shortest=1[out]" \
-map "[out]" -map 0:a? -c:v libx264 -c:a copy output.mp4

In this pipeline:

  1. chromakey removes the solid green background, turning it transparent.
  2. despill cleans up remaining green edges and reflections on the subject.
  3. overlay composites the cleaned foreground onto the background image.