Context Image Extractor
Pull the context frames out of a pre-generated video
- context_images
- boundary_frames
There are two ways to run the iterative-video pattern: generate each segment with only the previous tail as context, or pre-generate a whole rough video once and then regenerate it segment by segment, letting each pass refine only its own slice. The second approach gives the model a full picture of the scene, and ContextImageExtractor is what turns that rough video into the per-iteration context frames.
It takes a pre-generated context video and extracts the frames you actually need for the iteration loop: the very first frame, plus the last num_start_frames of every iteration. Those are the frames that get fed forward as the "start context" so the model knows where each segment begins.
How it works
Four inputs describe the video you're slicing:
context_images- the pre-generated video, as an IMAGE batch.num_start_frames- how many tail frames per iteration you carry forward (default 4).total_iterations- how many segments the final video will have (default 5).frames_per_iteration- how many frames each segment will be (default 81).
The math is straightforward indexing, and the source spells out the example: with num_start_frames=4, total_iterations=3, frames_per_iteration=81, the output is frames 1, then 78-81 (end of iteration 0), then 159-162 (end of iteration 1). The single output, boundary_frames, is exactly the set of frames your routers and samplers need as context. It's a pure index-and-extract node - no blending, no resizing, nothing that could surprise you.
Where it fits
Upstream of the iterative loop proper: generate your context video with a video model (the pack's docs suggest Wan), run this to get the boundary frames, then wire those into IterVideoRouter / the context inputs of your per-iteration sampler chain, with FrameAccumulator collecting the regenerated segments. It's the difference between "the model only saw the last few frames" and "the model saw where this whole shot is going" - which is how you get scene-wide consistency instead of drift.
Installing it
Part of Mickmumpitz-Nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/mickmumpitz/ComfyUI-Mickmumpitz-Nodes.git
or ComfyUI Manager → search "Mickmumpitz" → install → restart. No downloads; the pack's deps are numpy, Pillow and opencv-python.
Troubleshooting
- Output shorter than expected - if
total_iterations × frames_per_iterationexceeds the input video's length, indices get clamped to the last frame, and you'll see repeated frames at the tail. Make the numbers match the video you fed in. - Wrong context length -
num_start_framesmust match what your router expects downstream, or the first segment's context will be a different length than the rest. Keep them in sync. - "Why does the first frame repeat?" - the first output is the start-of-video frame, and the iteration tails include some overlap with it. That's intentional; the overlap is what lets consecutive segments agree on where they begin.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| context_images | IMAGE | — | |
| num_start_frames | INT | 41–99 | — |
| total_iterations | INT | 51–9999 | — |
| frames_per_iteration | INT | 811–9999 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| boundary_frames | IMAGE | — |