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

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

Select Masks

By KosinkadinkΒ·Created 3 years agoΒ·Updated 3 months agoΒ· 1,727
Select Masks πŸŽ₯πŸ…₯πŸ…—πŸ…’
  • mask
  • MASK
β—„indexes0β–Ί
β—„err_if_missingtrueβ–Ί
β—„err_if_emptytrueβ–Ί

Select Masks pulls specific masks out of a stack by index. You type which ones you want - 0, 4, 9, or a range like 0:12 - and it returns exactly those, in the order you asked. It's the mask-track counterpart to Select Latents: same index language, applied to masks instead of latents.

When you're doing per-frame masking across a clip, the mask stack is addressable like a list, and this is the node that lets you address it - filter it down, reorder it, reverse it, grab the last one.

The index syntax

The indexes field is a comma-separated string that understands single indices, negatives, and Python-style ranges with steps. Assuming 16 masks (indices 0–15):

  • 0 β†’ mask [0]
  • -1 β†’ the last mask, [15]
  • 0, 1, 13 β†’ those three, in order
  • 0:5, 13 β†’ 0,1,2,3,4, then 13 (ranges exclude the end index)
  • 0:-1 β†’ everything but the last
  • 0:5:-1 β†’ [4, 3, 2, 1, 0] (a negative step reverses the range)
  • 0:5:2 β†’ [0, 2, 4] (step of 2)
  • ::-1 β†’ the whole stack, reversed

Because the output follows the order you type, this reorders as easily as it filters. That ::-1 reverse is the quick way to play a mask sequence backwards.

Inputs and outputs

  • mask (MASK) - the stack to select from.
  • indexes (STRING, default 0) - the selection expression.
  • err_if_missing (BOOLEAN, default true) - throw an error if you reference an index that doesn't exist, instead of silently dropping it. Keep it on while building.
  • err_if_empty (BOOLEAN, default true) - throw if the selection resolves to nothing.

Output is a single MASK stack of exactly your selection.

Installing it

comfy.icu already ships VideoHelperSuite, so the node's there by default.

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

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

then restart ComfyUI. Kosinkadink's suite, standard for video and per-frame ControlNet setups.

Common issues

Ranges exclude their end index - 0:8 returns eight masks (0 through 7), not nine. That off-by-one is the most common mistake, and it's especially painful when you're trying to line a mask selection up with a matching frame selection. Select the same way on both tracks or they'll drift by one.

Leave err_if_missing on unless you have a specific reason not to. A silently shortened mask stack that no longer matches your images is the kind of bug that produces subtly-wrong results with no error to point at - the loud failure is the merciful one. Turn it off only when you're deliberately over-selecting from a variable-length stack and want the misses ignored.

If the node's absent from the menu, that's VideoHelperSuite failing to import (ffmpeg or a NumPy version clash). The startup log has the cause; reinstall through Manager.

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

Inputs (4)

NameTypeDefaultDescription
maskMASKβ€”
indexesSTRING0β€”
err_if_missingBOOLEANtrueβ€”
err_if_emptyBOOLEANtrueβ€”

Outputs (1)

NameTypeDescription
MASKMASKβ€”