Nodes/Image Processing Suite for ComfyUI/SAM2 Video Propagate (AnotherUtils)
ComfyUI Node

SAM2 Video Propagate (AnotherUtils)

Let SAM2 Chase the Subject Through Every Frame

By marcoc2·Created 2 years ago·Updated 5 months ago· 1
SAM2 Video Propagate (AnotherUtils)
  • model
  • state
  • MASK

This is the payoff node of the SAM2 video story. AnotherSAM2VideoAddPoints tells SAM2 what the object is on one frame; AnotherSAM2VideoPropagate then runs the segmentation forward through every frame of the clip, returning a full video mask you can use for rotoscoping, background replacement, subject isolation, or feeding a compositor. If you've ever wanted to cut a moving subject out of a video without keyframing a mask by hand, this is the closest ComfyUI gets to a one-click version.

It's part of AnotherUtils (marcoc2/ComfyUI-AnotherUtils), built as a port of the well-regarded comfyui-segment-anything-2 video node, bundled into the pack so the whole pipeline lives in one install. Like everything in the inference suite, it's self-contained: model loading, state, and propagation all happen inside the pack.

How it works

Propagation is the part of SAM2 that makes video feel like magic: given the object mask established on a keyframe, the model estimates the mask on the next frame, then the next, rolling the prediction forward. Occlusions and appearance changes get handled frame by frame, and the state from AddPoints - which remembers where the object was defined and on which frames - tells the propagator where to start. The node itself is nearly empty: it takes the model and state, verifies the model is in video mode, and asks the underlying SAM2 video predictor to run the whole roll-out. What comes back is one mask tensor covering every frame.

The inputs

Only two, both required, both ANOTHER_* custom types:

  • model - the ANOTHER_MODEL object from the SAM2 loader (must be video mode) or passed through from AnotherSAM2VideoAddPoints.
  • state - the ANOTHER_SAM2_STATE produced by AnotherSAM2VideoAddPoints. This is the wire you can't lose: no state, no propagation, and the node will error if you feed it a stale or mismatched one.

What comes out

A single MASK - a [B, H, W] tensor, one mask per video frame, at the video's original resolution. From here it can go to AnotherAnimatedCompositeMasked as the matte for a background replacement, into AnotherMaskMath to refine or combine, or straight to a save-node as an alpha sequence.

Installing it

Standard AnotherUtils install:

cd ComfyUI/custom_nodes
git clone https://github.com/marcoc2/ComfyUI-AnotherUtils.git

Restart ComfyUI, or search "AnotherUtils" in ComfyUI Manager. It needs the sam2 pip package and the SAM2 weights (auto-downloaded to models/sam2 on first use via the pack's loader) - if you skipped those, this node will complain loudly about a missing service.

Where people get burned

The biggest trap is state hygiene. The state is a snapshot of a specific tracking session; if you change the points, the frame index, or the video itself and don't re-run AddPoints, you're propagating a stale mask. When the result drifts mid-video, the fix is almost always "re-define the object on a frame where it's clear" and add a second AddPoints call to correct it - SAM2 propagation is robust but it does accumulate error over long clips. Also, this node is CPU/GPU heavy for long videos: a 30-second clip is hundreds of forward passes, so budget some patience (and VRAM) and test on a short slice first.

CategoryAnotherUtils/inference

Inputs (2)

NameTypeDefaultDescription
modelANOTHER_MODEL
stateANOTHER_SAM2_STATE

Outputs (1)

NameTypeDescription
MASKMASK