sch_mask
Pick one mask out of a batch by index
- masks
- selected_mask
The mask counterpart to sch_image, same job, different data type: hand it a batch of masks and an index, and it returns the mask sitting at that position. It exists for the same reason its image sibling does - anything frame-driven, whether that's per-frame masking across an animation, a masked-region schedule that changes over the course of a sequence, or a loop pulling the next mask out of a batch assembled earlier in the graph.
Both nodes live in the pack's data/schedule category, sitting alongside its animation-control tooling (the README's "General Control AD Stack" covers prompt scheduling, ControlNet scheduling and IP-Adapter scheduling for AnimateDiff-style work) - sch_mask is the building block you'd reach for when the thing that needs to change per frame is where an effect applies, not just what image is showing.
The inputs and outputs that matter
masks(required, MASK) - your mask batch. Could come from a batch of hand-painted masks, a segmentation model run across a sequence of frames, or masks accumulated earlier in a scheduling pipeline.current_frame(required, default 0, range 0–99999) - the index to pull from the batch. Same assch_image's field of the same name - drive it from a loop counter or an incrementing primitive rather than a static value if you want it to actually step through the sequence.max_frames(required, default 99999, range 1–99999) - an upper bound for coordinating with the rest of a scheduled pipeline; set it to your real sequence length if other nodes are relying on it.- Output:
selected_mask- a single mask, the one atcurrent_framein the input batch.
How to install it
Search ComfyUI-Apt_Preset in ComfyUI Manager, or clone it manually:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
install.bat handles Windows dependencies; on Linux or Mac, open it, read the pip installs, and run them yourself, or let ComfyUI Manager fill in anything missing on first load. No model files needed - this is pure batch indexing on masks.
Common issues & troubleshooting
Mask and image batches fall out of sync. If you're pairing this with sch_image to select an image and its corresponding mask for the same frame, both need the same current_frame value and both source batches need to be in the same order with the same length. A mismatch here - one batch built with a different sort order, or one frame shorter than the other - silently pairs the wrong mask with the wrong image rather than erroring, so verify batch lengths match before trusting the output.
Out-of-range index behavior is unclear. As with sch_image, this pack's README doesn't document what happens when current_frame exceeds the batch size - test it deliberately in your own install rather than assuming a safe clamp or wrap if you're driving the index from an automated loop.
Mask looks blank or fully solid at a given frame. Before suspecting this node, check the source batch at that same index directly (preview it before it reaches sch_mask) - an all-zero or all-one mask at a specific frame is usually a defect in whatever generated the batch, not in the selection step.
Only need a single static mask, not a schedule. If current_frame never changes across your runs, you don't need this node at all - just wire the mask directly.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | — | |
| current_frame | INT | 00–99999 | — |
| max_frames | INT | 999991–99999 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| selected_mask | MASK | — |