MatAnyone2 Select Frame
The One-Frame Gateway to Every MatAnyone2 Edit
- images
- image
- frame_index_used
Before you can cut a person out of a video, you have to decide which frame shows the person you're cutting. That's the entire job of MatAnyoneSelectFrame: it pulls exactly one frame out of your IMAGE batch and hands it to the editor so you can build the first-frame mask that the whole propagation depends on.
It's the smallest node in the pack and one of the most consequential, because in this workflow the first frame is everything. The Matte node propagates your first-frame mask through the entire clip - if you pick a frame where the subject is awkwardly posed, half-occluded, or about to turn around, the whole video inherits that bad starting point. The interactive editor opens on whatever frame this node hands it, so frame choice is your first quality lever.
How it works
Two inputs: images (the IMAGE batch) and frame_index (default 0). It returns image - that single frame, still as a [1, H, W, 3] IMAGE tensor so the editor and SAM Refine accept it - plus frame_index_used, the index you actually got. The index is clamped into range like everything else in this pack, so a too-big number silently lands on the last frame rather than exploding. That "used" output is the honest version of what happened, which matters if you're scripting across clips of different lengths.
ComfyUI counts from 0, so frame 0 is the first frame of the video, frame 1 the second, and so on. If your video came out of Slice Frames, the index is relative to the sliced batch - frame 0 after a slice starting at 10 is video frame 10.
Where it sits
In the demo flow it's Load Video → Slice Frames → Select Frame → Interactive SAM → Matte. It's also the frame you feed to SAM Refine in the scripted path. You can't really skip it - the editor and the prompt path both want a single frame, and IMAGE batches are how video arrives in ComfyUI.
Install
Ships in the MatAnyone2 Video Matting pack - ComfyUI Manager search "MatAnyone2", or clone https://github.com/dreamrec/MatAnyone2_ComfyUI into custom_nodes, pip install -r requirements.txt, python install.py, restart.
The gotcha
If the editor opens on a black frame or the wrong shot, you've got the wrong frame_index - check it against frame_index_used. And the real pro move: pick a frame where the subject's silhouette is clean and not mid-motion-blur. A blurry first frame produces a shaky first mask, and no amount of propagation fixes a bad seed. Spend your clicks on the frame that flatters the cut; the rest of the clip follows it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| frame_index | INT | 00–999999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| frame_index_used | INT | — |