Nodes/ComfyUI-SAM3/SAM3 Video Output
ComfyUI Node

SAM3 Video Output

Turn the tracked state into masks and frames you can use

By PozzettiAndrea·Created 9 months ago·Updated 27 days ago· 557
SAM3 Video Output
  • masks
  • video_state
  • scores
  • masks
  • frames
  • visualization
obj_id-1
plot_all_maskstrue

The SAM3 video nodes speak their own private language - SAM3_VIDEO_MASKS, SAM3_VIDEO_STATE, SAM3_VIDEO_SCORES - and nothing else in ComfyUI knows what to do with those. This node is the translator at the end of the chain. It takes the tracked masks and state from SAM3 Propagate and converts them into standard MASK and IMAGE outputs, so the rest of your graph - Video Combine, an inpainting pass, a compositor - can finally use them. Without this node your beautiful per-frame track is stuck inside SAM3's internal format.

So it's the exit ramp of the video pipeline: Video Segmentation seeds, Propagate tracks, Video Output delivers. It's not glamorous and it barely gets searched for, but skip it and you've got nothing wireable.

How it works

It reads the per-frame mask track plus the video state and renders them out three ways: the raw masks as a standard MASK batch, the original frames as an IMAGE batch, and a visualization where the masks are drawn over the frames so you can preview the result. If your propagation tracked more than one object, obj_id lets you pull out a single object's masks, and plot_all_masks controls whether the overlay shows everything or just your selection.

The inputs and outputs that matter

Two required:

  • masks (SAM3_VIDEO_MASKS) - the mask track from SAM3 Propagate.
  • video_state (SAM3_VIDEO_STATE) - the state that pairs with those masks (also from Propagate).

Optionals:

  • scores (SAM3_VIDEO_SCORES) - the per-frame confidence track, if you want it factored in.
  • obj_id (default -1 = all objects) - pick one tracked object by id instead of everything.
  • plot_all_masks (default on) - draw every mask on the visualization, or just the selected object when off.

Outputs: masks (MASK) - the per-frame masks in ComfyUI's normal type, ready for video inpainting or compositing; frames (IMAGE) - the source frames as an image batch; and visualization (IMAGE) - the overlay preview. Send masks + frames into whatever does your actual edit, and visualization to a preview so you can check the track before committing.

How to install it

Ships with the pack. Manager: search SAM3, install the highest version. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/PozzettiAndrea/ComfyUI-SAM3.git
cd ComfyUI-SAM3
pip install -r requirements.txt --upgrade
python install.py

then restart, with sam3.pt in ComfyUI/models/sam3/. The README notes an experimental comfy-env/pixi one-click installer.

Common issues & troubleshooting

Wrong types on the inputs. This node only accepts SAM3's video types - SAM3_VIDEO_MASKS and SAM3_VIDEO_STATE come straight out of SAM3 Propagate, not from any generic mask node. If the connection won't take, you're probably trying to feed it a normal MASK.

Empty or blank masks. Usually propagation upstream didn't actually track anything - check that SAM3 Video Segmentation seeded correctly and Propagate ran over the right frame range. Garbage in, blank masks out.

Visualization shows too many overlapping masks. If you tracked multiple objects, set obj_id to the one you want and turn plot_all_masks off to isolate it in the preview.

Mask count doesn't match your frames. Make sure Propagate covered the whole clip - a short start_frame/end_frame range there means fewer masks reach here. The output length follows what was actually tracked.

CategorySAM3/video

Inputs (5)

NameTypeDefaultDescription
masksSAM3_VIDEO_MASKSMasks from SAM3Propagate
video_stateSAM3_VIDEO_STATEVideo state for dimensions
scoresoptSAM3_VIDEO_SCORESConfidence scores from SAM3Propagate
obj_idoptINT-1Specific object ID for mask output (-1 for all combined). Changing this is fast - no re-inference needed.
plot_all_masksoptBOOLEANtrueShow all object masks in visualization (True) or only selected obj_id (False)

Outputs (3)

NameTypeDescription
masksMASK
framesIMAGE
visualizationIMAGE