Nodes/ComfyUI-VideoHelperSuite/Get Mask Count πŸŽ₯πŸ…₯πŸ…—πŸ…’
ComfyUI Node Runs on cloud

Get Mask Count πŸŽ₯πŸ…₯πŸ…—πŸ…’

Get Mask Count

By KosinkadinkΒ·Created 3 years agoΒ·Updated 3 months agoΒ· 1,724
Get Mask Count πŸŽ₯πŸ…₯πŸ…—πŸ…’
  • mask
  • count

Get Mask Count takes a batch of masks and tells you how many there are, as an integer. In a video workflow your masks travel as a stack - one per frame when you're doing per-frame masking - and this is how you read that stack's length out as a number the rest of the graph can use.

It's the mask sibling of Get Image Count and Get Latent Count. Trivial on its own; the value is that it lets your workflow measure its mask track instead of assuming it.

Why you'd reach for it

The most common reason is checking alignment. Per-frame masking only works if the mask count matches the frame count of whatever it's masking, and it's incredibly easy to knock those out of sync - a select, a split, a repeat, a load cap on one branch but not the other. Wire this node's output next to a Get Image Count (or Get Latent Count) and you can compare the two, or feed the number into a downstream node that needs the length.

It's also handy any time something wants "how many masks" as an input - a loop bound, a Video Combine timing calculation, a label on a preview.

A concrete example: you loaded a video, generated an animated matte from it, then thinned the frames with a select-every-nth on the image branch but forgot to thin the masks the same way. Everything runs, but the mask now leads the footage by a growing offset. Put a Get Mask Count next to a Get Image Count and the two numbers disagree immediately - you've turned a silent, drifting misalignment into a single obvious mismatch you can fix at the source.

How it works

No configuration. It reads the length of the mask batch along the frame axis and emits it as an INT.

Inputs and outputs

  • mask (MASK) - the batch to count.
  • count (INT, output) - the number of masks in it.

Installing it

On comfy.icu, VideoHelperSuite is already installed - the node's ready to go.

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

Nothing really breaks here - it's a count. The thing to internalize is that a surprising number is a symptom, not a fault: if your mask count doesn't match your frame count, this node just handed you the evidence that something upstream thinned, padded, or truncated one track and not the other. That mismatch is the actual bug you want to chase; masks silently misaligned to the wrong frames produce results that look "almost right" and are maddening to diagnose, so this node earns its keep as a sanity check.

If Get Mask Count is missing from the menu entirely, that's VideoHelperSuite failing to import - a missing ffmpeg or a NumPy version clash are the usual causes. Read the ComfyUI startup log for the real error and reinstall through Manager.

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

Inputs (1)

NameTypeDefaultDescription
maskMASKβ€”

Outputs (1)

NameTypeDescription
countINTβ€”