Nodes/ComfyUI-CustomNodePacks/Video Mask Editor
ComfyUI Node

Video Mask Editor

Hand-rotoscope a whole clip in the browser, keyframes and tweening included

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
Video Mask Editor
  • image
  • input_mask
  • mask
  • info
session_id
tween_modedistance_transform
feather0.0
threshold0.00

Video masking splits into two camps: let a model track (SAM2 video, optical flow, the pack's Mask Tracker) or do it by hand. The model route is fast but wanders; the hand route is precise but painful - until now. VideoMaskEditorMEC opens an in-browser video mask editor where you brush, erase, fill, or lasso masks on specific keyframes of your clip, and it tweens every frame in between automatically. It's the "painting rotoscoping" node from ComfyUI-CustomNodePacks, and for shots where the subject is too weird for a tracker, it's the honest answer.

The framing from the author: "pin per-frame keyframes, then tweens non-keyframed frames using distance-transform interpolation." That distance-transform detail is the whole trick, and it's what makes this node smarter than a naive morph.

How it works

You feed it image - the video batch - and the node opens an editor in the browser. There you scrub to a frame, paint a mask with brush / erase / fill / lasso (onion-skin shows you neighboring frames' masks for reference), and that becomes a keyframe. Paint on the frames where the mask matters, skip the frames where it doesn't, and the node fills the gaps.

The interpolation is the interesting part. Plain linear mode just blends mask values between keyframes, which produces mushy middle frames when a shape moves and deforms. The default, distance_transform, converts each keyframe mask to a signed distance field (distance from the boundary), interpolates those in frame space, and re-thresholds - so the shape moves and morphs smoothly instead of fading through mush. That's the difference between "looks like a crossfade of two masks" and "looks like the mask actually follows the thing."

Three tween modes total: distance_transform (default, best), linear (plain value blend), and hold (each keyframe holds until the next - no interpolation, good for discrete changes like on/off states).

Inputs and outputs that matter

  • image (IMAGE) - the video batch; it drives B/H/W.
  • session_id (STRING) - auto-set by the editor UI. The tooltip says it plainly: don't edit by hand.
  • tween_mode - distance_transform / linear / hold.
  • feather (FLOAT, default 0) - Gaussian edge feather in pixels, applied to the result.
  • threshold (FLOAT, default 0) - binarize after tweening; 0 keeps the soft mask.
  • input_mask (MASK, optional) - the fallback mask used if you haven't set any keyframes. Good for "start from an existing mask and hand-fix" workflows.

Outputs:

  • mask (MASK) - the full per-frame mask batch, (B, H, W).
  • info (STRING) - diagnostics about keyframes and tweening.

Where it fits

This is the manual fallback in the same niche the pack covers with models: when Mask Propagate or the tracker loses the subject - occlusions, a shape that changes every frame, something no flow field understands - you pin a few keyframes by hand and let the distance transform handle the rest. It also slots into the classic pipeline: extract a frame, use it to build an initial mask, then polish per-keyframe here. The threshold knob is worth knowing for downstream use - most inpaint/composite nodes want a hard binary mask, so set a threshold before feeding further.

Installing it

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git

restart ComfyUI or use Manager → "CustomNodePacks". The editor is browser-side JavaScript; the tweening is pure tensor math - no models, no downloads, and VRAM cost is just holding the batch.

The honest caveat

Tweening is not tracking. If the subject moves a lot between your keyframes, even distance-transform interpolation will smear - the node assumes you pin keyframes densely enough that the gaps are small. For that kind of footage you want a tracker first, this as the cleanup pass. Get the keyframe spacing right and it's shockingly good; space them too far apart and it's a reminder that rotoscoping was never a free lunch.

CategoryC2C/VideoMask

Inputs (6)

NameTypeDefaultDescription
imageIMAGEInput video batch (B,H,W,3). Drives B/H/W.
session_idSTRINGAuto-set by the editor UI. Don't edit by hand.
tween_modeCOMBOdistance_transformHow to interpolate non-keyframed frames.
featherFLOAT0.00–32Gaussian feather radius (px). 0 = none.
thresholdFLOAT0.000–1Binarize after tween. 0 = keep soft mask.
input_maskoptMASKFallback mask used if no keyframes are set.

Outputs (2)

NameTypeDescription
maskMASK
infoSTRING