AD_MaskExpandBatch
Pad a mask batch out to a target frame count
- mask
- MASK
This is the mask version of AD_ImageExpandBatch - same idea, different data type. If you've built a mask sequence for an animation and it's shorter than the frame count your workflow actually needs (AnimateDiff's context window, an LTX clip length, whatever downstream node is expecting a fixed count), this node pads it out to size instead of you having to redraw or re-export extra mask frames by hand.
Like its image counterpart, it lives in the pack's "backup" menu category, which reads as the author's signal that it's not the primary path in the current pack anymore, even though it still runs fine. If there's a newer masking node in Apt_Preset's active categories doing the same job, prefer that first; if not, this one works.
How it works
Pure count-matching, no generative interpolation involved - it duplicates existing mask frames according to whichever method you pick until the batch reaches size.
The inputs and outputs that matter
mask(MASK) - the batch you're padding.size(default 16, min 1) - target frame count. 16 lines up with AnimateDiff's native context window.method- same four options as the image version:expand- spreads padding across the batch.repeat all- loops the whole existing mask sequence.repeat first- pads by repeating the first mask frame.repeat last- pads by repeating the last mask frame.
Output is a single MASK batch at the target size.
How to install it
Through ComfyUI Manager, search "ComfyUI-Apt_Preset" and install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Then run install.bat (Windows, double-click) or pip install -r requirements.txt (Linux/Mac) per the pack's README, and restart ComfyUI. No model files needed - same as its image sibling, this is pure tensor duplication.
Common issues & troubleshooting
Mask stays frozen for a big chunk of the padded region. Expected with repeat first/repeat last - you're holding one mask value for however many frames get added. If the padded portion is a large fraction of your total, that freeze will be visible in whatever effect the mask is driving (inpainting region, blend region, etc.). Swap to expand or repeat all if a static hold isn't what you want.
Mask and matching image batch end up different lengths. If you're using AD_MaskExpandBatch on your mask and AD_ImageExpandBatch on your images, make sure you set the same size and, ideally, the same method on both - a mismatch between mask length and image length is a common source of shape errors further down a ComfyUI graph.
Node rejects a size smaller than the input batch. This node expands, it doesn't trim - if you need a shorter mask sequence, use a slicing tool instead, not this node with a smaller target.
Downstream node still complains about frame count. Confirm size actually matches what that specific downstream node wants - different nodes in an AD/LTX pipeline can expect different frame counts, so match to the consumer, not to a round number you picked arbitrarily.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | ā | |
| size | INT | 16 | ā |
| method | COMBO | 4 options: expand, repeat all, repeat first, repeat last |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | ā |