Nodes/ComfyUI-RGnodes/Mask Range Doctor
ComfyUI Node

Mask Range Doctor

Turn any frame range of a mask sequence white or black with one string

By rgamevfx·Created 7 months ago·Updated 7 months ago· 3
Mask Range Doctor
  • masks
  • masks
white_range
black_range

Ever had a mask sequence where a few frames are wrong and you'd give anything to just paint over them? That's this node. Mask Range Doctor takes a MASK sequence - the per-frame masks that tell Wan VACE where to regenerate - and sets whichever frames you name to solid white (1.0) or solid black (0.0). No per-frame mask editing, no batch of SetImage nodes, just a string.

It sits in the cleanup step of a VACE workflow. After VACE Inpaint Keyframe Insert drops keyframes in, the masks it leaves behind rarely need to be every frame - you want the frames you're going to inpaint marked white ("generate here") and the ones you're keeping black ("leave this alone"). Mask Range Doctor is the frame-range eraser/roller for that job.

How it works

You feed it one string for the frames to make white and one for the frames to make black, in a compact range syntax:

3,5,10-15,20

Commas pick individual frames, dashes pick a range, and both endpoints are inclusive - 10-15 is frames 10, 11, 12, 13, 14 and 15. Frames are 0-indexed, like everything in ComfyUI's video world. The node parses both strings, clones your mask tensor so nothing upstream is mutated, and writes 1.0 or 0.0 across the chosen frames.

Where people get burned: validation is strict, on purpose. A frame can't be in both ranges - white and black overlap raises an error rather than silently resolving to one. Any frame past the end of the sequence errors with the valid range spelled out for you. And 10-5 (start after end) is a hard error too. Annoying the first time, but it beats a mysteriously half-edited mask at frame 87.

Inputs and outputs that matter

Only three inputs exist, and two of them are the ranges:

  • masks (required, MASK) - your mask sequence, [B, H, W] where B is the frame count. This is what gets edited.
  • white_range (STRING) - frames to set to 1.0. Empty string skips it.
  • black_range (STRING) - frames to set to 0.0. Empty string skips it.

Output is a single masks (MASK) with the same shape as the input, so it drops straight back into whatever mask consumer you had. In a VACE graph that's usually the encode node's mask input, or another range node if you're iterating.

Installing it

This is one of four nodes in the rgamevfx/ComfyUI-RGnodes pack. Easiest via ComfyUI Manager - search "ComfyUI-RGnodes" and install. Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/rgamevfx/ComfyUI-RGnodes.git

Then restart ComfyUI. That's the whole dependency story: there's no requirements.txt, no model downloads, nothing beyond torch that ComfyUI already ships. It's a pure tensor utility - which is exactly why it never breaks on update.

Troubleshooting

  • "Overlapping frames detected" - a frame is in both white_range and black_range. Pick a side; it can't be both.
  • "Frame X is out of range" - remember it's 0-indexed and zero-based lengths bite everyone once. A 30-frame sequence is frames 0–29, not 1–30.
  • Input masks looked wrong dimensionally - the node expects a sequence in the batch dim, not a single mask. If your pipeline handed you one mask when you expected 120 frames, the error message will tell you the real valid range.
  • Nothing visibly changed - check you didn't leave both range strings empty. Empty means "do nothing," not "everything."
CategoryVace/VFX

Inputs (3)

NameTypeDefaultDescription
masksMASK
white_rangeoptSTRING
black_rangeoptSTRING

Outputs (1)

NameTypeDescription
masksMASK