Replace N-th Frame (Wan)
Swap a single frame in a Wan clip without re-generating — the surgical frame edit
- images
- replacement_image
- IMAGE
Sometimes the problem with a generated clip isn't the whole thing - it's one frame. Wan's I2V output drifts from your start image by the end of the clip, or frame 47 glitched, or you want the final frame to actually be your reference image so the thing can loop. Re-rolling the whole generation for that is absurd. Replace N-th Frame (Wan) exists for exactly these moments: it swaps one frame of an image sequence with a replacement image and hands the edited sequence back.
The "Wan" in the name is doing real work. Local video models like Wan output their frames as a single IMAGE tensor - shape [F, H, W, C] - and this node does frame surgery aimed straight at that representation. It works on any image sequence, but it's built for the Wan workflow.
How it works
Straight from the source, it's careful about not hurting you. It clones the input tensor first, so it never mutates the frames another node is still reading. Then:
frame_indexis clamped, not fatal - an out-of-range index silently becomes the last frame, with a console warning. 0-based, so frame N of an 81-frame clip is index 80.- If your replacement image has a batch, only its first frame is used.
- If the replacement's resolution differs from the sequence, it's auto-resized (bilinear) to match - no dimension error, though a small image upscaled to a big frame looks soft.
Then it overwrites that one frame and returns the sequence. That's the whole mechanism.
The inputs that matter
- images - your image sequence from a video sampler or VAE decode.
- replacement_image - the frame to put in. A single frame is ideal; anything else, only its first frame is taken.
- frame_index - which frame to replace, 0-based, default
0, up to10000.
Output is the edited IMAGE sequence, same shape as the input.
The canonical use is loop prep: generate with I2V, then replace the clip's final frame with your actual start image so the loop's endpoint lines up - the same first-and-last-frame trick behind this pack's loop nodes. Second use: patch a single glitched frame instead of re-running the sampler.
Install
ComfyUI Manager, search ComfyUI-AtlasUtils, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Yoon999/ComfyUI-AtlasUtils
Restart ComfyUI. No model downloads, no pip dependencies beyond what ComfyUI ships.
Where people get burned
- "My replacement didn't apply" - check the console. If
frame_indexwas out of range it clamped to the last frame with a warning, and if you counted from 1 instead of 0 you aimed one frame off. Both look like "nothing happened." - It's a blunt instrument. Hard replacement with bilinear resize - no blending, no optical flow, no morph. Perfect for a surgical fix or "make the endpoints match," wrong tool for a graceful transition. For that you want interpolation (the seamless-loop nodes in this pack) or a VACE-based join, which generates the transition rather than pasting a frame.
- Resolution mismatch won't error, which is friendly, but upscaling a tiny replacement to a 720p frame gives you a blurry frame in the middle of your clip. Feed a replacement at the clip's resolution.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| replacement_image | IMAGE | — | |
| frame_index | INT | 00–10000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |