SAM2 Video Mask Generator
Click a point on frame one, get masks for the whole video
- images
- MASK
This node is the lazy person's way to mask a whole video: you watch frame one, click a point or two on the thing you care about, and SAM2 tracks it for every frame that follows. No frame-by-frame rotoscoping, no painting masks by hand. It's the front end of the VideoMaMa pack, but it also works fine on its own as a general "make me video masks" tool.
What it actually does
It wraps SAM2's video predictor, which is the part of Segment Anything 2 that remembers an object across frames. You give it a batch of frames and a handful of point prompts placed on the first frame; it segments the object there, then propagates that segmentation forward through the video using its streaming memory. The result is one binary mask per frame: every pixel either in (the object) or out (everything else).
Meta's SAM 2 is Apache 2.0, and the default checkpoint this node uses is sam2.1_hiera_large - the big one. It works, it's just heavy. SAM 3's promptable text segmentation is everywhere in ComfyUI mask editors these days, but this pack predates that wave and was built against SAM2's point-and-track API.
The inputs and outputs that matter
- images - your video as a batch of frames (
IMAGE, [N, H, W, C]). Load with VHS Video Loader or similar; any node that hands you a frame stack works. - checkpoint_path - where the SAM2 checkpoint lives, default
checkpoints/sam2/sam2.1_hiera_large.pt(relative to the pack folder). If it's missing, the node downloads it from Hugging Face automatically. - config_name - the matching SAM2 config, default
configs/sam2.1/sam2.1_hiera_l.yaml. The node auto-downloads this too, and copies it into your installed SAM2 package if it's not there.
Output is MASK - [N, H, W] binary masks, one per input frame. That wires straight into the VideoMaMa Sampler's masks input, or into anything else that eats masks.
The point selector
Here's the part that isn't obvious from the input list. The node has a Select Points button widget on it. Click it and a dialog pops up over your first frame:
- Left click drops a green positive point ("this is the object")
- Right click drops a red negative point ("this is not it")
- Middle click / Ctrl+click removes a point
- + / - switches between positive and negative mode
More points means a more honest segmentation, and the node's own README is right that the pattern is positive points on the subject, negative points on background that keeps catching the mask. Hit Save and your clicks are baked into the node's hidden points_x/points_y/labels inputs - which is why they never show up as normal widgets.
One trap: if you don't open the editor, it still runs with a single default positive point at 512, 288 - roughly the middle of a 1024-wide image - and will happily mask whatever is near the center of frame one. Set your own points for a real subject; a stray default click masks the wrong thing, and then you blame the pack.
Installing it
The node only registers if SAM2 is importable, so this is the one install that genuinely matters:
cd /path/to/ComfyUI/custom_nodes/
git clone https://github.com/facebookresearch/sam2
cd sam2 && pip install -e .
Then restart ComfyUI. The pack also tries to auto-install SAM2 for you on restart, but the manual route is more reliable. If the node is simply absent from your node menu, SAM2 didn't import - check that the sam2 package is on the Python path ComfyUI uses.
Common issues
- Node missing from the menu - SAM2 isn't installed or isn't importable. See above. The pack also explicitly refuses a SAM2 copy that comes from
comfyui-rmbg(it detects it by path and bails), so if you have that installed, sort out which SAM2 is winning. - Config not found at
sam2_path/configs- the SAM2 install is incomplete; the configs directory ships with the repo, so a cleanpip install -e .fixes it. - Slow on long videos - SAM2 propagation is one forward pass per frame; this is a tracking cost, not a bug. Cut your clip down first.
Honest caveat: this is a research-grade wrapper with essentially no community footprint yet (zero reddit threads actually discuss it as of mid-2026). It works; you're the beta tester. For plain per-frame background removal you don't need it - RMBG or BiRefNet are the battle-tested defaults. Reach for this node when you want object masks tracked through a video, which is exactly what VideoMaMa wants as input.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| checkpoint_path | STRING | checkpoints/sam2/sam2.1_hiera_large.pt | — |
| config_name | STRING | configs/sam2.1/sam2.1_hiera_l.yaml | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |