Mask From Batch
Slice the frames you actually want out of a mask batch — Mask From Batch
- mask
- MASK
A video mask batch has 120 frames and you only care about 12 of them. Or you need to test a mask op on just the first frame before committing to the whole batch. wcx_MaskFromBatch is the slice: it takes a MASK batch, a starting position, and a length, and returns the contiguous run of masks you asked for.
The mechanism is a plain slice with friendly bounds handling. A start of 0 with length 1 gives you the first frame. Negative starts wrap from the end (start −1, length 1 → the last frame). If your start and length run past the end of the batch, it clamps instead of erroring - you get whatever valid frames exist and a shorter output. Inputs are mask (MASK), start (INT, default 0, range −4096 to 4096), and length (INT, default 1). Output is MASK, the sliced sub-batch. It even tolerates a single 2D mask by promoting it to a batch first, so a one-frame "batch" behaves like one.
Where it fits in a real workflow:
- Extract one frame for inspection. Pull frame 3 out of a batch, preview it, tweak your mask pipeline, then rerun the batch. It's the mask equivalent of pulling a frame out of a latent batch for a quick look.
- Subset a long sequence. Process frames 20–50 of a 120-frame mask set without loading or touching the rest.
- Pair with
IsMaskBlackto check a specific frame rather than the whole batch - remember that node's all-or-nothing test across the batch, which is exactly why slicing first matters.
Gotchas:
- It returns a sub-batch, not a single flat mask. A slice of length 1 is still shaped as a length-1 batch. Most mask nodes handle that; some fussy consumers want a squeezed single mask, so be ready to drop a dimension.
- It only slices contiguously. Want frames 0, 3, and 7? That's three calls or a list node, not this one. Contiguous runs only.
- No index-checking surprises - clamping does the safety. Ask for more than exists and you just get fewer frames; no crash, but also no warning that you asked for the impossible.
Standard light install:
# ComfyUI Manager: search "ComfyUI-Practical-Tools" → Install → restart
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
# restart ComfyUI
It's a boring slice node with good boundaries - exactly the kind of thing that's forgettable until the moment you need frame 41 and don't feel like rebuilding the graph to get it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| start | INT | 0-4096–4096 | — |
| length | INT | 1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |