WAN Three Frame To Video (Badman)
Start, middle, and end keyframes in one node
- positive
- negative
- vae
- start_image
- middle_image
- end_image
- clip_vision_start_image
- clip_vision_middle_image
- clip_vision_end_image
- positive
- negative
- latent
- debug_mask_visualization
Wan ships two native ways to anchor a video to an image: give it a start frame and let it generate forward (I2V), or give it a start and an end frame and let it fill the middle (first-last-frame, FLF2V). What Wan doesn't give you out of the box is a way to also pin down what happens in the middle of the clip. This node adds that third anchor - start, middle, and end keyframes, all in one conditioning node - with masking that blends around each one instead of hard-cutting to it.
How it works
This slots in right where Wan's own image-conditioning nodes go, upstream of your KSampler. You give it positive and negative conditioning, a vae, and your target width/height/length/batch_size, same as any Wan video setup. Then, optionally, you plug in start_image, middle_image, and end_image - all three are optional, so you can use it as a plain FLF2V node (start + end, skip middle), a start-only I2V node, or the full three-anchor version.
The two settings that make it more than a start/end node: middle_frame_position places your middle keyframe anywhere along the timeline as a fraction of total length (0.5 is dead center, the default, but you can push it earlier or later), and frame_blend_width controls how many frames around each anchor get blended so the transition into and out of a keyframe is smooth rather than a visible snap. This is the same general problem AnimateDiff's SparseCtrl solved years earlier for image models - "provide a starting frame, an ending frame, and the motion module fills the rest" - extended here to a third anchor point and built for Wan specifically.
The inputs and outputs that matter
start_image/middle_image/end_image(optional) - the keyframes you're anchoring to. Leave any of them unplugged and the node just doesn't anchor there.middle_frame_position(default 0.5, 0–1) - where in the clip the middle keyframe lands.frame_blend_width(default 8) - how wide the smoothing region is around each anchor.length(default 81, step 4) - total frame count. The step-of-4 constraint isn't arbitrary: Wan was trained on frame counts following a 4n+1 pattern (81 = 4×20+1), so stick to values on that grid rather than typing an arbitrary number.clip_vision_start_image/_middle_image/_end_image(optional) - feed these from a CLIP Vision Encode per keyframe for the extra conditioning boost Wan's I2V pipeline expects; the pack concatenates them per the README.debug_show_mask(optional, off by default) - flip it on to get a visualization of the blend mask instead of debugging blind.
Outputs: positive and negative - your original conditioning, now carrying the keyframe/mask info, wired straight into KSampler in place of your originals. latent - the shaped latent for the run, into KSampler's latent_image. debug_mask_visualization - only meaningful with debug_show_mask on; wire it to a Preview Image to see the mask.
How to install it
Search ComfyUI-BadmanNodes in ComfyUI Manager, or clone it manually:
cd ComfyUI/custom_nodes
git clone https://github.com/MariusKM/ComfyUI-BadmanNodes
Restart ComfyUI. This node doesn't bundle a model - you still need a Wan I2V/FLF2V-capable checkpoint, its VAE, and (if you're using the CLIP vision inputs) a matching CLIP vision model loaded elsewhere in your graph. It's just the conditioning glue; the heavy lifting is still Wan's.
Common issues & troubleshooting
The clip doesn't respect your middle keyframe. Double-check middle_image is actually wired in - since all three keyframe inputs are optional, it's easy to leave one unplugged and get a plain start/end (or even unanchored) result without an error telling you why.
Transitions look muddy on a short clip. If your middle_frame_position sits close to either end, a large frame_blend_width can overlap the two neighboring anchors' blend regions. Pull the blend width down for short, tightly-packed clips.
Weird artifacts or errors around frame count. Check length sits on the 4n+1 grid the step value enforces (81, 85, 77, and so on) - moving off it is asking Wan to do something it wasn't trained for.
Output looks flat without the CLIP vision inputs. They're optional and the node runs fine without them, but you're leaving conditioning quality on the table - this is the same extra signal native Wan I2V nodes use, not something unique to this pack.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| vae | VAE | — | |
| width | INT | 83216–16384 | — |
| height | INT | 48016–16384 | — |
| length | INT | 811–16384 | Total video length in frames |
| batch_size | INT | 11–4096 | — |
| middle_frame_position | FLOAT | 0.500–1 | Position of middle frame as fraction of total length (0.0-1.0) |
| frame_blend_width | INT | 81–32 | Number of frames to blend around each keyframe for smooth transitions |
| start_imageopt | IMAGE | — | |
| middle_imageopt | IMAGE | — | |
| end_imageopt | IMAGE | — | |
| clip_vision_start_imageopt | CLIP_VISION_OUTPUT | — | |
| clip_vision_middle_imageopt | CLIP_VISION_OUTPUT | — | |
| clip_vision_end_imageopt | CLIP_VISION_OUTPUT | — | |
| debug_show_maskopt | BOOLEAN | false | Output debug visualization showing mask as white overlay |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |
| latent | LATENT | — |
| debug_mask_visualization | IMAGE | — |