MASK to SEGS for Video
Wrap a mask into SEGS the video detailer can use
- mask
- SEGS
MASK to SEGS for Video is the adapter that turns a mask into the SEGS structure the Impact Pack's video detailer expects. If you already have a mask - one you painted, one from CLIPSeg, one from a segmentation step - and you want to run detailing across a clip, this is how you package it so SEGSDetailer For Video can consume it. Mask in, SEGS out, built to handle batch masks that span multiple frames.
Why a whole node just to convert a mask? Because SEGS isn't just a mask - it's a mask plus crop coordinates plus per-region bookkeeping, and the video path needs that bundle to carry a mask per frame. When you feed a single mask, this node can apply it across the whole clip; when you feed a batch mask (a different mask per frame), it wraps each one. It was originally the "MASK to SEGS For AnimateDiff" node and got renamed to "for Video" because the same trick works for any per-frame video, not just AnimateDiff.
How it works
The node reads your mask (single or batch), finds the region(s), and builds a SEGS with a crop box around each, sized by crop_factor. With a single mask it converts it to cover the whole clip; with a batch mask, the pack notes that the contour-fill feature is disabled - because filling contours frame-by-frame across a moving mask isn't well-defined. The bbox_fill and contour_fill toggles control whether the mask interior gets filled to a solid box or its outline traced and filled, which matters when your mask is hollow or ragged. The output SEGS then feeds the video detailer, or the still Detailer (SEGS) if you're not doing video after all.
The inputs and outputs that matter
mask(required) - the mask to convert. Single mask (applied across the clip) or batch mask (one per frame).crop_factor(default 3) - how much context around the mask ends up in each crop. Same meaning as everywhere else in the pack: too tight starves the detailer of blend context, too loose wastes resolution.combined(default false) - whether to merge everything into one region or keep detections separate.bbox_fill(default false) - fill each detection out to its full bounding box rather than keeping the mask shape.contour_fill(default false) - fill the interior of an outline mask. Note it's disabled automatically for batch masks.drop_size(default 10) - ignore regions smaller than this.
Single output: SEGS - feed it into SEGSDetailer For Video (then SEGS Paste), or a still detailer.
How to install it
Install the pack via ComfyUI Manager (search ComfyUI Impact Pack, install, restart), or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
python -m pip install -r requirements.txt # ComfyUI's python; python_embeded on portable
then restart. No models for this node itself - it's a mask-to-SEGS converter. You'll need a video stack (AnimateDiff-Evolved or a Wan pipeline) upstream and the video detailer downstream to make use of the SEGS. Linux: libgl1-mesa-glx and libglib2.0-0 for OpenCV.
Common issues & troubleshooting
My per-frame masks didn't fill in. That's the documented behavior: contour_fill is turned off for batch masks. If you need filled regions per frame, pre-fill the masks before this node, or feed a single mask if the region doesn't move much across the clip.
The crop is missing part of the moving subject. A single mask converted across the whole clip only fits where the subject started. If the subject moves, use a batch mask (one per frame) so each frame's crop tracks it - or generate the SEGS with a video detector like SAM2 Video Detector that follows the subject.
SEGS came out empty. The mask was blank or every region fell under drop_size. Check the mask actually has content, and lower drop_size if your regions are genuinely small.
Do I need this or a video detector? If you already have a mask, this is the cheap path - no detection model required. If you need the pack to find the subject across frames, skip this and use SAM2 Video Detector (SEGS) or Simple Detector for Video, which produce the batch-mask SEGS for you.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| combined | BOOLEAN | false | — |
| crop_factor | FLOAT | 3.01–100 | — |
| bbox_fill | BOOLEAN | false | — |
| drop_size | INT | 101–16384 | — |
| contour_fill | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SEGS | SEGS | — |