Nodes/ComfyUI-VideoMaMa/VideoMaMa Sampler
ComfyUI Node

VideoMaMa Sampler

Rough masks in, clean matte out, one diffusion step

By okdalto·Created 7 months ago·Updated 7 months ago· 59
VideoMaMa Sampler
  • pipeline
  • images
  • masks
  • MASK
seed42
max_resolution1024
fps7
motion_bucket_id127
noise_aug_strength0.00

This is the payoff node of the pack. You feed it video frames plus a rough mask for each frame, and it hands back a refined mask - one that handles the messy edges a coarse mask always leaves behind: hair, motion blur, the border where the subject meets the background. Instead of another segmentation model hallucinating edges from scratch, VideoMaMa leans on a Stable Video Diffusion prior that knows what a moving subject looks like, and uses it to clean up your mask. It's the step after SAM2, not a replacement for it.

The README's older "VideoMaMa Run" node is this same node under its current name, so don't go hunting for a missing "Run" - this is it.

How it works

Worth understanding, because it explains every setting on this node. It's a single-step diffusion pass, not a 20-step denoise. The sampler:

  1. Resizes your frames and masks so the longest axis hits max_resolution (preserving aspect ratio, aligned to a multiple of 8).
  2. Embeds the first frame through CLIP to get the appearance context.
  3. VAE-encodes the frames and the masks into latent space.
  4. Concatenates the noisy latent, the frame latents, and the mask latents along the channel axis and runs the fine-tuned UNet exactly once.
  5. Decodes the output, averages RGB down to grayscale, and resizes back to your original input resolution.

Because it's one forward pass, "generation" here is really refinement: it fixes edges and temporally-consistent detail, but it won't invent a subject that wasn't roughly selected.

The inputs that matter

  • pipeline - the VIDEOMAMA_PIPELINE from the VideoMaMa Pipeline Loader; one loader feeds this node.
  • images - your video frames as an IMAGE batch, e.g. from VHS Video Loader.
  • masks - one per frame; this is where SAM2 Video Mask Generator plugs in. The frame counts must match, and the code checks it explicitly.
  • max_resolution (default 1024, 256–2048) - the longest axis it processes at. A 1920x1080 clip at 1024 becomes 1024x576 internally, then the result is resized back to full res. Lower = less VRAM and faster; higher = more matte detail.
  • seed (default 42) - reproducibility of the latent noise. Bump it if a result looks unlucky.
  • fps (default 7) - the frame rate of your clip; the model conditions on it. If your footage is 24/30 fps, set it close to real.
  • motion_bucket_id (default 127, 1–255) - how much motion the model expects. The README's guidance holds: 50–100 subtle, 150–200 dynamic.
  • noise_aug_strength (default 0.0) - SVD's noise augmentation. At 0 the refinement stays close to your input; push it up and you're asking for invented detail, which you rarely want in a matte.

Output is MASK - refined [N, H, W] grayscale masks at the original input resolution. Wire it into an alpha-over/compositing node, a matte-based background swap, or whatever consumes masks.

Installing it

Same pack install as the rest:

cd /path/to/ComfyUI/custom_nodes/
git clone https://github.com/okdalto/ComfyUI-VideoMaMa
cd ComfyUI-VideoMaMa
pip install -r requirements.txt

Restart, and the node appears under VideoMaMa. ComfyUI Manager's search for "VideoMaMa" does the same thing. The first run will pull the SVD base model and the VideoMaMa UNet automatically - gigabytes, so expect the first queue to sit in "downloading" for a while. You don't need SAM2 to use this node if you have masks from somewhere else - MatAnyone output, a per-frame BiRefNet pass, even hand-painted ones - the sampler only cares that the counts match.

Common issues

  • "Number of image frames (X) must match number of mask frames (Y)" - a real, raised-in-code error and the most common one. Your mask source dropped or padded a frame somewhere; equalize the counts and it goes away.
  • OOM - max_resolution is the lever; drop from 1024 to 768 or 512. The loader's vae_encode_chunk_size and CPU offload also matter.
  • Masks that look smeared or over-smoothed - you're pushing noise_aug_strength or the input mask is bad. This is a refiner; fix the input, not the settings.
  • Odd results on long clips - temporal consistency is the model's strength, but very long footage eats VRAM and time. Slice it into shorter chunks.

Reality check: this is a research wrapper with no real community footprint yet (zero substantive reddit discussion as of mid-2026), so don't expect a pile of shared workflows or tuned settings. You're breaking trail. But the loader is the fiddly part; this node - pipeline in, frames and masks in, clean matte out - is where the pack does something genuinely different from a per-frame BiRefNet cutout.

CategoryVideoMaMa

Inputs (8)

NameTypeDefaultDescription
pipelineVIDEOMAMA_PIPELINE
imagesIMAGE
masksMASK
seedINT420–18446744073709550000
max_resolutionINT1024256–2048
fpsINT71–60
motion_bucket_idINT1271–255
noise_aug_strengthFLOAT0.000–1

Outputs (1)

NameTypeDescription
MASKMASK