SAM3 Track to Mask
Pull real masks out of a SAM3 video track
- track_data
- masks
SAM3_VideoTrack gives you a SAM3_TRACK_DATA object full of tracked masks, but it can't do anything with it - it just hands the data forward. This node is the other half of the handshake: it unpacks that tracking data into plain MASK tensors your graph can actually use. Track first, convert here, then inpaint, composite, or filter to your heart's content.
Think of the pairing as track → masks → work. The preview node shows you the tracking as a video; this one gives you the material. If you're building a background-replacement or object-removal pipeline, this is the node that closes the loop between "SAM3 followed the object" and "the mask goes into a Set Latent Noise Mask".
How it works
The tracking data stores masks in a packed per-object format - one slot per object per frame - precisely because it's compact. This node unpacks that, keeps only the objects you asked for, unions them into a single mask per frame, and resizes back to the original video resolution. Nothing fancy, and that's the point: it's the boring, reliable bridge between an exotic custom data type and the standard MASK that every mask-consuming node in ComfyUI already speaks.
The inputs and outputs that matter
- track_data - straight from
SAM3_VideoTrack's output. One connection and you're set. - object_indices - a comma-separated string like
0,2,3selecting which tracked objects to include. Empty string means all objects. This is your selective-edit lever: track four people, convert only person1to a mask, and leave the other three untouched. Object indices correspond to the numbered IDs you see inSAM3_TrackPreview's overlay, so check the preview to learn which index is which.
The masks output is one mask per video frame, batch-aligned with the frames you fed in - feed it straight to an inpaint node, a mask-prep sequence, or a compositor.
The one gotcha
The output is a union of the selected objects - if you pick 0,2, you get one mask containing both, not two separate masks. For most edits (remove everything selected) that's exactly what you want. If you actually need per-object masks to edit them differently - say, a different prompt for person 0 than person 2 - run the node once per index rather than trying to split the union apart afterward. It's a minor inefficiency but the result is clean and it saves you a mask-segmentation step.
One more: if tracking found nothing (which happens when a track dies), you'll get a batch of empty masks rather than an error - ComfyUI's way of telling you the object vanished from frame. Check the preview first, then decide whether the empty frames are a genuine miss or a reason to re-track with a better seed mask.
Also new to all this? The same SAM3_TRACK_DATA → this node → masks pattern is how you feed tracked objects into inpainting and compositing, which is the whole reason anyone tracks a video object in the first place. Track once, convert, and the mask-based half of your workflow - the part that's been around for years - takes over.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| track_data | SAM3_TRACK_DATA | — | |
| object_indices | STRING | Comma-separated object indices to include (e.g. '0,2,3'). Empty = all objects. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |