ComfyUI Node
SAM2Matting Video Background (Streaming)
Streams a native ComfyUI VIDEO through temporal matting, composites the foreground over a solid color, and returns both that native H.264 VIDEO and a lossless white-on-black matte VIDEO. Tracking frames and mattes are disk-backed, so host RAM does not grow with the full-resolution clip length. Connect either result to ComfyUI Save Video.
SAM2Matting Video Background (Streaming)
- model
- video
- initial_mask
- streaming_options
- video
- matte_video
◄mask_frame0►
◄mask_threshold0.50►
◄background_color#808080►
◄state_devicegpu►
CategorySAM2Matting/video
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| model | SAM2MATTING_VIDEO_MODEL | Loaded SAM2Matting temporal video model. | |
| video | VIDEO | Native, file-backed ComfyUI video. Use Load Video Path (Native) for files too large for browser upload. | |
| initial_mask | MASK | Seed mask for one source frame: white is the foreground subject to keep, black is background. | |
| mask_frame | INT | 00–2147483647 | Zero-based video frame that matches initial_mask. Tracking propagates forward and, when needed, backward from this frame. |
| mask_threshold | FLOAT | 0.500–1 | Threshold used only to turn the seed mask into a binary tracking prompt. It does not threshold the soft output matte. |
| background_color | STRING | #808080 | Solid RGB background written behind the extracted foreground, as a six-digit hex color such as #808080. |
| state_device | COMBO | gpu | Where the bounded temporal tracking state is stored. gpu is faster and avoids system-RAM pressure; cpu saves VRAM but is slower and uses host RAM. |
| streaming_optionsopt | SAM2MATTING_STREAMING_OPTIONS | Optional advanced settings from SAM2Matting Streaming Options. Leave disconnected for recommended defaults. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| video | VIDEO | File-backed H.264 MP4 with the tracked foreground composited over the chosen color. |
| matte_video | VIDEO | File-backed lossless matte video: white foreground, black background, and soft gray edges. |