Nodes/ComfyUI-VideoHelperSuite/Merge Masks πŸŽ₯πŸ…₯πŸ…—πŸ…’
ComfyUI Node Runs on cloud

Merge Masks πŸŽ₯πŸ…₯πŸ…—πŸ…’

Merge Masks

By KosinkadinkΒ·Created 3 years agoΒ·Updated 3 months agoΒ· 1,724
Merge Masks πŸŽ₯πŸ…₯πŸ…—πŸ…’
  • mask_A
  • mask_B
  • MASK
  • count
β—„merge_strategyβ–Ύβ–Ί
β—„scale_methodβ–Ύβ–Ί
β—„cropβ–Ύβ–Ί

Merge Masks joins two groups of masks into one, A followed by B. If you've split a mask sequence apart, processed the halves separately, and now want them back as a single track - or you just have two mask stacks you want to concatenate in order - this is the node that stitches them together.

It's the reassembly half of the split/merge pair. Split Masks carves a stack in two; Merge Masks puts two stacks back into one, in the order you wire them.

Why you'd reach for it

Concatenating mask sequences comes up whenever you build a clip in pieces: mask the first section one way, the second another, then merge into a continuous track for the full render. It's also how you assemble a mask timeline from separate sources - an intro matte plus a main-section matte, joined end to end.

The wrinkle that makes this node more than a plain concat: the two mask groups might not be the same resolution. Merge Masks handles that mismatch for you rather than erroring, which is why it carries a few extra settings.

How it works

The output is simply group A's masks followed by group B's. When A and B have different resolutions, the node has to pick a target size and rescale the odd one out - that's what the widgets control.

  • merge_strategy decides which resolution wins: match A always uses A's size, match B uses B's, match smaller picks the smaller by area, match larger picks the larger.
  • scale_method is the interpolation used when rescaling - nearest-exact, bilinear, area, bicubic, or bislerp. For masks, nearest-exact keeps edges hard; the smoother methods soften them.
  • crop chooses how to handle an aspect-ratio difference: disabled stretches to fit, center crops to preserve aspect ratio.

Inputs and outputs

  • mask_A (MASK) - the first group; appears first in the output.
  • mask_B (MASK) - the second group; appended after A.
  • merge_strategy, scale_method, crop - the resolution-handling settings above.

Outputs:

  • MASK - the combined stack, A then B.
  • count (INT) - the total length of the merged group.

If both inputs are already the same size, the strategy and scaling settings never come into play - it's a straight concatenation.

Installing it

comfy.icu has VideoHelperSuite pre-installed, so nothing to do.

Locally: ComfyUI Manager β†’ search ComfyUI-VideoHelperSuite β†’ install β†’ restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite

then restart ComfyUI.

Common issues

Order matters and isn't symmetric: A comes first, B second. Swap the wires and your merged timeline plays in the wrong order. There's no reordering after the fact beyond re-wiring, so get A and B right.

If your merged masks look stretched or unexpectedly cropped, the culprit is a resolution mismatch plus your crop/merge_strategy choice. Stretched means crop: disabled forced an aspect change; a chopped matte means crop: center cropped to fit. Decide which you actually want. And for crisp mask edges, prefer nearest-exact as the scale method - bilinear/bicubic will feather the boundary, which is rarely what you want in a mask.

If the node's missing entirely, that's the pack failing to import (ffmpeg or a NumPy clash); check the startup log and reinstall through Manager.

CategoryVideo Helper Suite πŸŽ₯πŸ…₯πŸ…—πŸ…’/mask

Inputs (5)

NameTypeDefaultDescription
mask_AMASKβ€”
mask_BMASKβ€”
merge_strategyCOMBO4 options: match A, match B, match smaller, match larger
scale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, bislerp
cropCOMBO2 options: disabled, center

Outputs (2)

NameTypeDescription
MASKMASKβ€”
countINTβ€”