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 aregreen(default) orblue.mix: Sets the strength of the spill removal, ranging from0.0to1.0. The default is0.5. Higher values eliminate more color but can introduce discoloration.expand: Controls the spill expansion factor, ranging from0.0to1.0. Default is0.0. Increasing this expands the spill suppression further into edge pixels.red/green/blue: Adjusts the scale coefficient for specific color channels (ranging from-100to100).
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.mp4This 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
mixif green fringes remain around the edges. - Lower
mixtoward0.3if edges appear too purple or gray. - Increase
expandif 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.mp4Full 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.mp4In this pipeline:
chromakeyremoves the solid green background, turning it transparent.despillcleans up remaining green edges and reflections on the subject.overlaycomposites the cleaned foreground onto the background image.