Gift Chroma Master · 一键专业抠像
Green-screen keying that actually holds up on video
- image
- screen_color
- source_mask
- inside_mask
- outside_mask
- cleaner_mask
- spill_mask
- foreground_rgb
- foreground_alpha
Chroma keying in ComfyUI has a well-known failure mode: it's fine for a single still, and then the moment you feed it a clip, the matte flickers, the edge goes green, and the hairline dissolves. Gift Chroma Master is the node in this suite that tries to solve exactly that. It bundles the professional three-stage chain - screen key, edge cleaner, linear-light despill, the same shape as After Effects' Keylight + Key Cleaner + Advanced Spill Suppressor - into one node that processes whole video batches on the GPU in chunks. It's an independent implementation, not an AE clone, but built by someone who has shipped this kind of work.
Before you grab it, note what this node is not for. If you're cutting a subject out of an arbitrary photo, AI background removal (BiRefNet, InSPyReNet) is the right tool - that's segmentation, a commoditized problem. Chroma keying is the deterministic route: you shot against green or blue, so the screen color is knowable, and you want controllable, frame-consistent results. This one is for footage you already have on a screen.
How it works
The three stages run in order. The keyer samples the screen color - by default auto, which clusters the border pixels and decides green vs. blue on its own, or you can force green/blue or hand it a screen_color. It builds the base matte in linear light, then the cleaner works only in the edge band: it restores fine detail (hair, smoke, glass) that the raw key chewed up and - the part stills can't show - suppresses matte "chatter" across frames. The despill stage removes green/blue contamination from the foreground in linear light with arbitrary-hue protection. If you've only ever keyed in an editor, this is the same stack, just node-ified.
For video, the defaults matter: batch_mode=ordered_video enables safe temporal stabilization (each frame borrows context from its neighbors, with scene-cut detection to reset), and screen_sampling=stable_video smooths the sampled screen color and auto-resets on an obvious cut. Feed it unrelated stills instead, and switch to independent_images so frames don't borrow from each other.
The inputs that actually matter
screen_mode- start onauto, drop togreen/blue/manualthe second auto misbehaves.screen_gain(default 1.1) - "higher keys out more," per the author. Your first lever for residue.clip_black/clip_white- the matte's floor and ceiling.clip_blackis where you'll live.shrink_grow_px- negative pulls the matte in, positive expands it. The edge-chasing knob.despill_amount+spill_range- how hard and how wide the green removal bites.
Two optional inputs hide the real power: performance_mode (auto/cuda/cpu) and gpu_chunk_size (default 8, about 2.6GB of transient VRAM at 720p). In auto mode it follows ComfyUI's device policy, chunks long clips, and on CUDA OOM retries 8→4→2→1 before falling back to CPU. Outputs land back on CPU so a long clip doesn't pin your VRAM. Reference numbers from the author's RTX 5880 Ada: 96×720p in about 1.9s (~51fps), ~2.6GiB peak.
Outputs and the alpha polarity trap
You get two outputs: foreground_rgb (straight, unpremultiplied RGB - transparent pixels are not zeroed) and foreground_alpha, where 1=foreground, 0=transparent. That's foreground-opacity semantics, the opposite of what ComfyUI's built-in Load Image MASK means. Don't wire foreground_alpha into a node expecting a transparency mask; run it through GiftChromaMasterPackRGBA when in doubt. That mismatch is the single most common way to get a "keyed but looks like a grey blob" result.
Install
ComfyUI Manager (search "ComfyUI-GiftHelperSuite") or:
cd ComfyUI/custom_nodes
git clone https://github.com/lingziwyh/ComfyUI-GiftHelperSuite.git
Then restart ComfyUI. No pip dependencies - it uses the PyTorch ComfyUI already ships. On first start it copies three demo assets into ComfyUI/input (set GIFT_HELPER_SKIP_EXAMPLE_ASSETS=1 to opt out); the demo workflows also need ComfyUI-VideoHelperSuite, but that's only for the examples.
Tuning and troubleshooting
The author ships actual recipes in README_GIFT_CHROMA_MASTER.md. Background residue: screen_gain 1.15–1.35, clip_black 0.07–0.12, shrink_grow_px −0.30 to −0.80. Hair/smoke/glass getting eaten: clip_black 0.015–0.040, clip_rollback 0.35–0.65, detail_recovery 0.70–0.90, shrink toward 0. Green fringe left on edges: despill_amount 0.90–1.00, spill_range 0.65–0.85, spill_mode=ultra, edge_recovery 0.25–0.45.
Auto screen detection is genuinely fragile in the obvious places - subject filling the frame, colored lights or captions at the edge, a desaturated or badly underexposed screen, motion blur, glass. Uneven lighting and shadows on the screen are the classic real-world killer (community reports hit this constantly with phone-shot green screens); that's when you force green and lean on screen_gain. Input must be finite-range sRGB/Rec.709 in [0,1] - log/ACES/HDR footage gives garbage or an explicit error, and NaN/Inf are rejected outright. Feed it linearized media and you'll wonder why the matte is wrong.
Inputs (33)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| screen_mode | COMBO | auto | 自动、约束为绿/蓝,或使用手动颜色。 |
| screen_color | COLOR | #00ff00 | 仅在 manual 模式使用。 |
| batch_mode | COMBO | ordered_video | 视频批次会启用安全的时域稳定;独立图片不会互相借帧。 |
| screen_sampling | COMBO | stable_video | 稳定视频会平滑取色,并在明显换镜/换幕色时自动重置。 |
| screen_gain | FLOAT | 1.100–3 | 越高抠除越多。 |
| screen_balance | FLOAT | 0.800–1 | — |
| preblur_px | FLOAT | 0.600–12 | — |
| clip_black | FLOAT | 0.0600–0.95 | — |
| clip_white | FLOAT | 0.9850.05–1 | — |
| clip_rollback | FLOAT | 0.250–1 | — |
| shrink_grow_px | FLOAT | -0.20-12–12 | 正值扩张前景,负值向内收缩。 |
| softness_px | FLOAT | 0.450–12 | — |
| cleaner_strength | FLOAT | 0.720–1 | — |
| edge_radius | FLOAT | 3.00–32 | — |
| alpha_contrast | FLOAT | 0.04-1–1 | — |
| detail_recovery | FLOAT | 0.580–1 | — |
| reduce_chatter | FLOAT | 0.350–1 | 仅 ordered_video 生效。 |
| spill_mode | COMBO | standard | 2 options: standard, ultra |
| despill_amount | FLOAT | 0.820–1 | — |
| spill_range | FLOAT | 0.550–1 | — |
| desaturate | FLOAT | 0.200–1 | — |
| luma_restore | FLOAT | 1.000–1 | — |
| edge_recovery | FLOAT | 0.350–1 | — |
| source_alpha_mode | COMBO | multiply | 3 options: multiply, ignore, add_inside |
| source_mask_polarity | COMBO | transparency | ComfyUI Load Image 的 MASK 通常是 transparency。 |
| source_maskopt | MASK | — | |
| inside_maskopt | MASK | — | |
| outside_maskopt | MASK | — | |
| cleaner_maskopt | MASK | — | |
| spill_maskopt | MASK | — | |
| performance_modeopt | COMBO | auto | auto 会在 ComfyUI 允许时使用 CUDA,并把长视频分块以限制显存。 |
| gpu_chunk_sizeopt | INT | 81–32 | 每次送入显卡的帧数;720p 下 8 约占 2.6GB 临时显存。显存紧张可改 4。 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| foreground_rgb | IMAGE | Straight / 未预乘的前景 RGB。 |
| foreground_alpha | MASK | 前景不透明度:1=前景,0=透明。不要把它当作 Load Image 的透明度 MASK。 |