Pulls chroma keys and composites believable green-screen shots end to end: plate quality checks, keyer tuning, spill suppression, garbage mattes, and matching the subject's lighting and grade to the new background so the shot reads as real. Triggers on requests to key out a green or blue screen, remove a video background, composite a subject onto a new background, or fix green spill and rough edges.
./install.sh green-screen-compositingname: green_screen_compositing description: Pulls chroma keys and composites believable green-screen shots end to end: plate quality checks, keyer tuning, spill suppression, garbage mattes, and matching the subject's lighting and grade to the new background so the shot reads as real. Triggers on requests to key out a green or blue screen, remove a video background, composite a subject onto a new background, or fix green spill and rough edges.
Turn a green or blue screen plate into a finished composite that a viewer believes. Covers the full chain: deciding the shot is keyable at all, pulling a clean matte, killing spill, cutting frame junk with garbage mattes, and selling the composite by matching light, grade, and edges between subject and background. Ships two lanes: a fast ffmpeg path for straight shots, and a Blender compositor path for shots with hair, motion, or uneven screens.
A bad plate wastes every minute after it. Check these and report the verdict honestly:
Shooting from scratch? Light the screen and the subject as two independent jobs. The screen wants soft, even light with no hotspots or shadows. The subject wants light that matches the final background: direction, color temperature, and a rim light from behind to separate them from the plate. Never try to kill spill by counter-lighting with magenta (on green screens); modern keyers remove spill digitally and counter-lighting wrecks skin tone.
bin/key_blender.py.Sample the real screen color first. Real screens are around 0x20B040 to 0x3EB34C, almost never pure 0x00FF00. Grab a frame and eyedropper it; key the color you see, not the color you wish for.
# Tune in this order: similarity up until edges chew, back off one notch,
# then raise blend until the edge looks natural.
ffmpeg -i fg.mp4 -i bg.mp4 -filter_complex "\
[0:v]chromakey=0x20B040:0.12:0.05,despill=type=green:mix=0.5:expand=0.1,crop=iw-40:ih-40:20:20[keyed];\
[1:v][keyed]overlay=shortest=1[out]" \
-map "[out]" -map 0:a? -c:v libx264 -crf 18 -pix_fmt yuv420p out.mp4
Notes:
chromakey works in YUV space and forgives real-world screen unevenness; colorkey (RGB space) suits only flat digital screens. For filmed footage, use chromakey.despill=type=green handles it.crop is a poor-man's garbage matte for frame-edge junk. For irregular junk, use Blender lane masks instead.overlay, background first, keyed subject on top.bin/key_blender.py builds the full node graph headless and renders:
bin/key_blender.py --fg fg.mp4 --bg bg.mp4 --out composite.mp4 \
--key-color 0x20B040 --frames 120
The graph it builds: Movie Clip (fg) -> Keying node (built-in despill, clip black/white, edge dilate/feather) -> Color Spill (stubborn-edge spill) -> Alpha Over onto the background plate -> Group Output. Settings and the rationale for each node are in references/tuning.md.
After the render, watch actual frames. Check edges at 200% zoom: hair, glasses, translucent objects. Noisy or chattering edges mean the matte needs work, not more similarity.
A technically clean key still reads fake if the subject and background live in different worlds:
despill=type=blue. Choose blue when the subject wears green.publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.