Nodes/CRT-Nodes/Mask Temporal Enhancer (CRT)
ComfyUI Node

Mask Temporal Enhancer (CRT)

Mask Temporal Enhancer (CRT)

By PGCRT·Created 2 years ago·Updated a day ago· 132
Mask Temporal Enhancer (CRT)
  • mask
  • mask
processing_deviceauto
auto_repairbalanced
repair_strength1.00
max_repair_gap3
temporal_window5
temporal_strength0.55
edge_strength0.80
edge_radius3
fill_holestrue
hole_threshold0.50
cleanup_modeclose gaps
cleanup_radius1

Mask Temporal Enhancer (CRT) smooths a sequence of masks across time. You feed it the per-frame masks you got from frame-by-frame face or object detection, and it returns masks that no longer blink, pop, or jitter between frames. If you've ever composited a detected subject across a video and watched the mask edge shimmer like a faulty green screen, you already know why this node exists.

Per-frame detection is unstable in a very specific way. Run a segmenter on frame 1, frame 2, frame 3, and the mask for the same subject changes shape slightly every frame - a few pixels of boundary wobble here, a momentary dropout there, a hole that appears and vanishes. Individually each mask is fine; played back, the sequence flickers. The fix is temporal processing: each output mask is influenced by its neighbors in time, so the wobble averages out and a one-frame dropout gets repaired from the frames around it. That's the whole job, and it's a video problem - the KB's inpainting and video work both keep running into it.

The controls map onto that job pretty cleanly. temporal_window (default 5) is how many neighboring frames each mask considers; bigger = smoother but laggier. temporal_strength (default 0.55) is how much of that temporal averaging you actually apply. auto_repair (off/conservative/balanced/aggressive, default balanced) sets how hard it works to fill gaps across frames, with repair_strength and max_repair_gap (default 3) governing the reach - a dropout longer than max_repair_gap frames is left alone rather than guessed. edge_strength and edge_radius control feathering so boundaries stay soft instead of hard-edged, and fill_holes plus hole_threshold mop up interior speckles. cleanup_mode (off/close gaps/open speckles/close then open) adds a classic morphological pass, with cleanup_radius for its size. And processing_device (auto/input/cuda/cpu) lets you force where the math runs - the default auto is right for almost everyone.

The one input that matters is mask (a batch of masks, one per frame - match the ordering to your video frames), and the single output is the enhanced mask batch, ready to feed a compositor, an inpaint, or a per-region detailer. A sensible starting point: defaults, then raise temporal_strength only if the result still flickers, and lower it if you see the mask "lagging" behind fast motion - too much temporal smoothing drags edges, and that's the classic overcorrection.

Install with the pack (ComfyUI Manager → search "CRT-Nodes", or clone https://github.com/plugcrypt/CRT-Nodes.git into custom_nodes and restart). It's numpy/torch processing - no models, no downloads. If your video masks are steady already, you don't need it; if they're not, it's the difference between a composite that looks broken and one that holds still.

CategoryCRT/Mask

Inputs (13)

NameTypeDefaultDescription
maskMASK
processing_deviceCOMBOauto4 options: auto, input, cuda, cpu
auto_repairCOMBObalanced4 options: off, conservative, balanced, aggressive
repair_strengthFLOAT1.000–1
max_repair_gapINT31–24
temporal_windowINT51–31
temporal_strengthFLOAT0.550–1
edge_strengthFLOAT0.800–1
edge_radiusINT31–32
fill_holesBOOLEANtrue
hole_thresholdFLOAT0.500–1
cleanup_modeCOMBOclose gaps4 options: off, close gaps, open speckles, close then open
cleanup_radiusINT10–16

Outputs (1)

NameTypeDescription
maskMASK