Key Mix(KeyMixStage)
Key Mix composites two video streams using a mask as the key.
Key Mix Stage
Description
Key Mix composites two video streams using a mask as the key. It takes a pair of video inputs (video_a and video_b) and mixes them together according to the supplied matte, so that masked regions are drawn from one source while the remaining regions are drawn from the other. The result is emitted as a single COMFYTV_VIDEO output.
The matte can be supplied either as a moving mask_video (one mask per frame) or as a static mask image applied across the whole clip. The invert_mask switch flips the key, swapping which video is visible inside the masked area and which is visible outside it.
Inputs
| Input | Type | Required | Default | Description |
|---|---|---|---|---|
invert_mask | BOOLEAN | Yes | false | Inverts the matte before it is used. With the default false, white areas of the mask take one input and black areas take the other. Enable this to swap the foreground and background selection. |
video_a | COMFYTV_VIDEO | No | - | One of the two videos to mix. Typically the background or plate that fills the unmasked regions. |
video_b | COMFYTV_VIDEO | No | - | The other video to mix. Typically the foreground element that appears inside the masked regions. |
mask_video | COMFYTV_VIDEO | No | - | A per-frame matte video. Use this when the key changes over time, such as a rotoscoped or generated animated matte. |
mask | COMFYTV_IMAGE | No | - | A static matte image. Use this when the key does not change between frames. |
All four video and mask inputs are optional individually, but a usable composite needs the two video sources plus at least one matte source. When both mask_video and mask are connected, the per-frame mask_video is the appropriate choice for animated keys and the static mask for a constant key; connect the one that matches your footage rather than relying on both at once.
Outputs
| Output | Type | Description |
|---|---|---|
| Video | COMFYTV_VIDEO | The mixed video, with video_a and video_b combined according to the matte (and optionally inverted). |
Usage Notes
- The matte controls the mix: bright or white values select one video and dark or black values select the other. If the composite looks reversed, enable
invert_maskinstead of regenerating the matte. mask_videosupplies a mask for each frame, so it should match the frame count of the video inputs for a stable result.maskis a still image, so it applies the same key to every frame. This is useful for locked-off shots, fixed vignettes, or constant shape mattes.- The matte and the video inputs should share a compatible resolution so the key lines up with the footage.
- Because both videos are optional inputs, Key Mix can be used flexibly, but in normal compositing you will connect a background to one video input, a foreground to the other, and drive the blend with a mask.
Comments
Sign in with GitHub to join the discussion.