Nodes/ComfyTV/Key Mix
ComfyUI Node

Key Mix

The stage where your key finally lands on a background

By jtydhr88·Created 3 months ago·Updated about 15 hours ago· 725
Key Mix
  • video_a
  • video_b
  • mask_video
  • mask
  • video
force_run_token0
project_id
parent_output_id0
mix1.00
invert_maskfalse
alpha_opover

Every keying pipeline has a moment where the subject and the background finally meet, and in ComfyTV that moment is Key Mix. After you've pulled a matte with the Keyer and cleaned it with Matte Morphology, this is the node that puts your subject over the new background where the mask says to. It's a small node with a simple job, and it's the payoff stage of the whole Keying category - nothing before it means anything until A actually lands on B.

ComfyTV is the canvas-style app layer on ComfyUI where every operation is its own node and results flow downstream. Key Mix is one of the "compositing" stages hiding inside the Keying category.

How it works. Key Mix takes two videos and a mask, and for every frame composites video A over video B using the mask as the alpha: white in the mask means A shows, black means B shows, gray is a blend. The mix control scales that alpha from 0 (all B) to 1 (full mask-driven), so it doubles as a global "how much of this composite is in" dial for a soft reveal. invert_mask flips the selection, and alpha_op changes what "over" even means - from the plain over composite to add, subtract, max or min, which are the classic blend modes you use when you're compositing glows, light leaks or texture rather than a person.

The inputs that matter. The force_run_token, project_id and parent_output_id inputs are internal plumbing - ignore them. The real set:

  • video_a - the foreground (your keyed subject).
  • video_b - the background it lands on.
  • mask_video or mask - the matte. You can feed either a video-shaped matte (e.g. the mask output of Mask Propagate) or a single mask image; the stage accepts one or the other.
  • mix - 0–1 global mix of the composite, default 1 (fully applied).
  • invert_mask - flip which side is foreground.
  • alpha_op - over, add, subtract, max, min.

Both videos and a mask are required - the node refuses to run with a clear error if either is missing. The single video output is your composite, ready for a color pass or export.

Install. Install the pack once:

cd ComfyUI/custom_nodes
git clone https://github.com/jtydhr88/ComfyTV

Restart ComfyUI (a real backend restart, not a browser refresh) and the stage appears under ComfyTV → Keying. ComfyUI Manager - search "ComfyTV" - also works. Zero Python dependencies (the pack's pyproject.toml ships an empty dependencies list) and no model downloads for compositing - this is per-frame math on your GPU. The usual install gotcha applies: on ComfyUI Desktop or with multiple installs, clone into the running instance's absolute path (from the startup log) or the node never registers.

Where people get burned. The most common failure is wiring the Keyer's default matte output straight into a player and concluding the pipeline is broken - no, the matte is input to Key Mix, and the Keyer only outputs a composite when you explicitly switch its output knob. Second: feeding Key Mix a mask and a foreground that don't share resolution - the composite scales to A's size, so a mismatch shows up as a weirdly cropped or padded result. And if your matte has noisy edges, Key Mix will faithfully composite every single jagged pixel; the fix is upstream (Matte Morphology, not more mix dialing). One thing people underuse: mix at 0.8 with invert_mask off gives a soft, partially-transparent composite that's great for ghosting effects without any extra keying.

CategoryComfyTV/Keying

Inputs (10)

NameTypeDefaultDescription
force_run_tokenINT00–2147483647Internal — bumped on Run to invalidate ComfyUI's input cache.
project_idSTRINGInternal — populated by the projectStore on the frontend.
parent_output_idINT00–2147483647Internal — lineage parent set by spawn handlers on the frontend.
mixFLOAT1.000–1
invert_maskBOOLEANfalse
alpha_opCOMBOover5 options: over, add, subtract, max, min
video_aoptCOMFYTV_VIDEO
video_boptCOMFYTV_VIDEO
mask_videooptCOMFYTV_VIDEO
maskoptCOMFYTV_IMAGE

Outputs (1)

NameTypeDescription
videoCOMFYTV_VIDEO