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

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

Split Masks

By KosinkadinkΒ·Created 3 years agoΒ·Updated 3 months agoΒ· 1,727
Split Masks πŸŽ₯πŸ…₯πŸ…—πŸ…’
  • mask
  • MASK_A
  • A_count
  • MASK_B
  • B_count
β—„split_index0β–Ί

Split Masks cuts a mask stack into two groups at an index you choose. The first split_index masks go to output A, the rest go to output B. It's the mask-track version of Split Latents, and the natural partner to Merge Masks - split apart, treat each piece differently, glue back together.

When you're doing per-frame masking, the mask stack is a timeline. This lets you slice that timeline in two so a section of your clip gets a different mask treatment than the rest.

Why you'd reach for it

Two clean uses. First, treating parts of a clip differently - hold out the opening frames' masks, or peel off a leading section to process on its own. Second, manual chunking: split off a fixed-size group, do something with it, then split the next group off the remainder, when you want explicit control over how a long mask sequence is carved up.

How it works

split_index is the boundary - it's the index of the first mask that lands in B. So split_index = 12 puts masks 0–11 in A (twelve of them) and 12-onward in B. The node reports both group sizes, which matters because of one edge case.

That edge case, worth memorizing: if you feed it fewer masks than split_index, it doesn't error. Everything goes into A and B comes out empty. So A_count equals split_index unless the input was shorter, in which case it equals the input length. The count outputs are how you tell which happened.

Inputs and outputs

  • mask (MASK) - the stack to split.
  • split_index (INT, default 0) - the boundary; first index that goes to B.

Outputs:

  • MASK_A - the first group.
  • A_count (INT) - how many landed in A (see the edge case).
  • MASK_B - the remainder.
  • B_count (INT) - how many landed in B.

Wire the counts into your logic when chunking - they're how you detect "ran out of masks."

Installing it

comfy.icu bundles VideoHelperSuite already, so there's nothing to install.

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

The empty-B surprise is the big one. Set split_index = 16, feed a 10-mask stack, and B comes out empty - that's documented behavior, not a bug: a too-short input dumps everything into A. Check B_count before assuming B has frames.

The default split_index of 0 sends everything to B and nothing to A, which catches people who dropped the node in and queued without setting it. Set the index to what you mean.

And the alignment reminder that applies to every mask-count-changing node: after splitting, make sure whichever group you keep still matches the images or latents it's meant to mask. A mask stack that's silently a different length than its frames misaligns the whole clip. If the node itself is missing from the menu, that's the pack failing to import - check the startup log (ffmpeg or NumPy, usually) and reinstall through Manager.

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

Inputs (2)

NameTypeDefaultDescription
maskMASKβ€”
split_indexINT0-9007199254740991–9007199254740991β€”

Outputs (4)

NameTypeDescription
MASK_AMASKβ€”
A_countINTβ€”
MASK_BMASKβ€”
B_countINTβ€”