Nodes/ComfyUI-SuperNodes/🐧 SAM3 Video Track (Mask Index)
ComfyUI Node

🐧 SAM3 Video Track (Mask Index)

Track a video object from the middle, not just frame 0

By sonnyboxΒ·Created 11 months agoΒ·Updated 12 days agoΒ· 13
🐧 SAM3 Video Track (Mask Index)
  • images
  • model
  • mask
  • track_data
β—„start_index0β–Ί
β—„bidirectionaltrueβ–Ί

ComfyUI's native SAM3 Video Track node seeds tracking from a mask on the first frame, and that's the whole problem. The object you care about often isn't in a usable form at frame 0 - it's mid-scene, partially occluded, or just smaller and uglier than the frame where it shows its face. This node fixes the one thing the native node can't: it lets you draw the seed mask on any frame (start_index), then tracks forward from there. Flip on bidirectional and it also tracks backward to frame 0, so you get a full clip of masks instead of a partial one.

SAM3 is Meta's current segmentation tier in ComfyUI, and it's genuinely the tool for this job - dedicated SAM3 nodes became the masking workhorse through 2026, with Comfy Org itself recommending SAM3 for video object tracking. This node is a modified reimplementation of the native video track node, with the seeding logic changed.

How it works. You feed it the video as a batched image, a loaded SAM3 model, and a mask (or masks, one per object) that belongs to the start_index frame. It runs the SAM3 model's forward_video from that frame to the end, then - if start_index is past 0 and bidirectional is on - reverses the earlier frames, tracks backward, and stitches the two halves together. The output mask count always equals the input frame count: frames neither run covered stay empty rather than being dropped, which keeps your downstream batching sane. Object slots line up between the halves because both runs seed from the same mask in the same order.

Inputs. images (video frames as a batched image [B,H,W,C]), model (a loaded SAM3 model, via ComfyUI's SAM3 loader), mask (masks for the start_index frame - one per object), start_index (default 0; 0 means "just like the native node"), and bidirectional (default on; ignored when start_index is 0). That's it - there's no text prompt here. For text-prompted detection, use the native SAM3 Video Track node; this one is mask-driven by design.

Output. A single SAM3_TRACK_DATA socket, which wires into the native SAM3 Track to Mask node (to get per-frame masks for compositing or inpainting) or SAM3 Track Preview (to eyeball the tracks). You can't read the tracking straight off this node - the downstream track-to-mask node is what turns it into something usable.

Use it when: the object appears cleanly mid-clip, or you already have a mask from another stage (segmentation, an earlier edit) on a non-zero frame and just want propagation from there. The KB's background-removal doc is worth a skim for the SAM3 context - the one real catch there is that some SAM3 tooling needs Triton, which is a genuine obstacle on Windows. That's a property of the model stack, not this node specifically.

Install. Same as the rest of the pack - ComfyUI Manager β†’ search "ComfyUI-SuperNodes", or git clone https://github.com/sonnybox/ComfyUI-SuperNodes into ComfyUI/custom_nodes and restart. The pack itself adds no heavy dependencies (just matplotlib). What you will need is the SAM3 model weights, downloaded via ComfyUI Manager's model tab, and a current ComfyUI with the native SAM3 nodes - this pack targets the newer extension API.

Gotchas. The backward pass re-processes the pivot frame, so it costs start_index + 1 extra forward steps - on a long clip starting mid-way, that's a real compute bump, and it's exactly why bidirectional has an off switch. And remember the mask has to belong to the start_index frame; put the mask on the wrong frame and the track silently starts somewhere unexpected.

CategorySuperNodes/Video

Inputs (5)

NameTypeDefaultDescription
imagesIMAGEVideo frames as a batched image [B,H,W,C].
modelMODELLoaded SAM3 model.
maskMASKMask(s) for the start_index frame to track (one per object).
start_indexINT00–99999Frame the mask belongs to (0 = first frame, matching the native node). Tracking runs forward from here.
bidirectionalBOOLEANtrueAlso track backwards from start_index to frame 0 by reversing the earlier frames. Off leaves those frames empty. Ignored when start_index is 0.

Outputs (1)

NameTypeDescription
track_dataSAM3_TRACK_DATATrack data for SAM3 Track to Mask / SAM3 Track Preview.