AD_frame_replace
Swap or pull a frame range out of an image batch
- images
- masks
- replace_img
- replace_mask
- IMAGE
- MASK
Anyone who's run a long AnimateDiff or LTX batch knows the pain: 90 frames come out fine except frame 34, which has a mangled hand or a flickering artifact, and re-rendering the whole clip to fix one frame is a waste of GPU time. AD_frame_replace is the surgical-fix node for exactly that - it either lets you pull a specific frame range out of a batch to inspect or export, or slot a replacement frame (and its mask) into that range and get the full batch back, patched.
How it works
It's index-based, not content-aware - you tell it where to look (start_index, num_frames) and what mode to run in (type), and it either hands you just that slice or stitches your replace_img/replace_mask into the batch at that position and returns everything.
The inputs and outputs that matter
start_index(default 0, min -1) - where the frame range begins. The-1floor suggests it supports counting from the end of the batch, worth testing if you need to target the tail of a sequence rather than counting forward from zero.num_frames(default 1) - how many frames the range covers, starting atstart_index.type- the mode switch:choose frame outputjust extracts and returns that slice, whilereplace frame and output allswaps that slice for your replacement content and returns the entire original batch with the patch applied.images/masks(optional) - the source batch you're operating on.replace_img/replace_mask(optional) - the patch content, only relevant in replace mode.
Outputs are IMAGE and MASK - either the extracted slice or the full patched batch, depending on which mode you ran.
How to install it
Via ComfyUI Manager: search "ComfyUI-Apt_Preset", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Then, per the pack's README, run install.bat on Windows (double-click it) or pip install -r requirements.txt from inside the folder on Linux/Mac if there's no .bat support on your system. Restart ComfyUI. This particular node does no model loading and needs no extra downloads - it's pure batch-index plumbing.
Common issues & troubleshooting
Nothing changes in replace mode. Double-check you're actually on replace frame and output all - the default type is choose frame output, which silently just extracts a slice and discards your replace_img/replace_mask inputs entirely. If you wired up replacement content and nothing's happening downstream, you're probably still in extract mode.
Off-by-one frame mismatch. start_index plus num_frames defines the range being touched - if your patch is landing one frame early or late, it's worth explicitly counting frame position in your batch rather than eyeballing it in a preview, especially since batch previews and node-graph frame counts don't always agree at a glance.
Replacement content doesn't match the batch's frame count. In replace mode you're inserting a fixed-size chunk (num_frames long) into a fixed position - if replace_img/replace_mask supply a different number of frames than num_frames expects, that's a mismatch worth fixing at the source rather than assuming the node will silently pad or truncate for you.
Trying to use this for anything content-aware. This node doesn't detect bad frames for you - it's a manual scalpel, not an auto-fix. You still need to know which frame is broken (from a preview or a failed run) before you can tell this node where to cut.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| start_index | INT | 0-1–4096 | — |
| num_frames | INT | 11–4096 | — |
| type | COMBO | choose frame output | 2 options: choose frame output, replace frame and output all |
| imagesopt | IMAGE | — | |
| masksopt | MASK | — | |
| replace_imgopt | IMAGE | — | |
| replace_maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |