Mask Repeat
One mask, N frames — for when a video needs the same region every time
- mask
- mask
The name tells you everything: give it one mask, tell it how many copies you want, and it hands back a batch of that same mask repeated count times. It sounds almost too boring to be useful, until you're doing anything frame-based - then "apply this one region to all frames" is exactly the operation you keep needing and rebuilding by hand.
Why it exists
Most ComfyUI image nodes want an [B, H, W] batch so they can process frames together. Video frames come out of a video loader as a batch, but a single saved mask, or a mask you drew once in an editor, is a lone [H, W] frame. If you wire a one-frame mask into a node that's iterating over 24 frames, the shapes don't line up. Mask Repeat is the one-liner fix: one mask in, count identical masks out, same size as your video batch.
How it works
Mechanically it's a reshape, not a copy-paste job. The node takes your mask, unsqueezes it onto a new leading dimension, repeats that along the new axis count times, then flattens back to [count * B, H, W]. So if you feed in a single mask with count = 24, you get 24 frames. If you feed in a 4-frame mask batch with count = 6, you get 24 frames too - each original frame repeated six times. The shape math handles both, which is handy when your mask batch and video batch don't share a frame count.
The inputs that matter
Three, and all of them are beginner-friendly:
- mask (
MASK) - the mask (or mask batch) to repeat. - count (
INT, default 1, up to 4096) - how many repeats. This is the control you'll actually touch. - invert (
BOOLEAN, default off) - flips the mask to its negative before repeating, i.e.1 - mask. Useful when your video needs the outside region masked instead of the inside.
One output:
- mask (
MASK) - the repeated batch.
Installing it
ComfyUI Manager → search ComfyUI-1hewNodes → install → restart, or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart ComfyUI after. No model downloads for this node - it's tensor manipulation only. The usual pack note applies: the requirements file drags in heavyweight pip packages (including rembg and ultralytics for the detection nodes), and the pack relies on ComfyUI's newer comfy_api.latest API, so keep ComfyUI updated or the nodes won't register.
Common issues
The one real gotcha is the interaction between count and an existing batch: doubling up on a multi-frame batch is easy to misread. If you feed a 4-frame mask with count = 6, you get 24 frames where each frame appears six times consecutively - so your first frame repeats six times before the second frame ever shows. If you wanted alternating frames, repeat isn't your node; you'd use an interleave or index step instead. And on the invert toggle: it inverts before repeating, so the whole batch flips consistently, no surprises mid-stream.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| invert | BOOLEAN | false | — |
| count | INT | 11–4096 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |