Frame Context Fit
Squeeze a 240-frame video into an 80-frame context window
- images
- images
- key_frame_data
- frame_indices_report
Video models have a fixed number of context frames they can look at, and your timeline is almost always longer than that. You can't just feed 240 frames to a model with an 80-frame window. Frame Context Fit is the compression layer: it takes a long image sequence and fits it into exactly the window size you specify, while keeping the scene's structure readable - key frames get held and repeated so the model actually registers them, and the in-between motion is sampled with a controllable easing curve.
This is the brain behind the pack's context handling, and it pairs with Anchor Frame Extractor to pull clean single frames back out afterward.
How it works
The output is built as repeating segments:
[key frame × repeats] [eased intermediate frames] [key frame × repeats] ...
key_frame_interval- pick a key frame every N input frames (e.g. 80 → frames 0, 80, 160…). These are the story beats the model must see.key_frame_repeats- how many times each key frame is repeated in the output (default 5). Repeats are how a context-limited model gets to actually register a frame instead of glancing at it once.context_window- the total number of output frames (default 80). The compression math fits everything into this.easing_mode- 16 options (linear, all the ease_in/out quad/cubic/sine/expo/back variants). This controls temporal density between keys: ease_out packs more intermediate frames near the start of each segment, so motion feels faster at the beginning and slows toward the key frame. Linear is the honest default.include_last_frame- always include the very last input frame as a final key (with repeats) even if it doesn't land on an interval boundary. Keep this on unless you have a reason not to.
There's also num_start_frames, which is where it gets specific to this pack's iterative-video loop: when you're generating with overlapping start frames, key frames should land at iteration boundaries. Set it to your num_start_frames and the node places the first key at key_frame_interval, then every (key_frame_interval - num_start_frames) frames after - matching where each new iteration actually begins. Set it to 0 for uniform spacing.
Outputs
images- the compressed batch, sized exactlycontext_window.key_frame_data(STRING, JSON) - where each key-frame group sits in the output. Feed this to Anchor Frame Extractor.frame_indices_report(STRING) - a readable map of which input frames landed where.
Where it fits
Any workflow that must respect a model's context limit: feeding a long video into a context-image conditioner, or maintaining scene continuity across iterative passes. The pack is by Mickmumpitz, whose YouTube workflows are all about keeping scenes and characters consistent across long generations - this node is how long timelines survive contact with a fixed window.
Installing
ComfyUI Manager → "Mickmumpitz" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/mickmumpitz/ComfyUI-Mickmumpitz-Nodes
Deps: numpy, Pillow, opencv-python. Nothing to download.
Gotchas
If context_window is smaller than your key frames alone would fill (key_frame_repeats × key-frame count), the node falls back to repeated key frames trimmed to the window - intermediates vanish entirely. Lower key_frame_repeats or raise the window if you're losing all motion. And if you change key_frame_interval after extracting anchors, re-extract: the group boundaries moved. The output count is exact (context_window), so if your model needs precisely N frames, this node is the piece that guarantees it.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| context_window | INT | 804–4096 | Total number of output frames (the context window size). |
| key_frame_interval | INT | 801–10000 | Pick a key frame every N input frames (e.g. 80 → frames 0, 80, 160 ...). When using iterative video generation with num_start_frames > 0, the first interval is this value and subsequent intervals are (key_frame_interval - num_start_frames). |
| num_start_frames | INT | 00–1000 | Number of overlapping start frames in iterative video generation. When > 0, key frames are placed at iteration boundaries: first at key_frame_interval, then every (key_frame_interval - num_start_frames) frames. Set to 0 for uniform spacing. |
| key_frame_repeats | INT | 51–100 | How many times each key frame is repeated in the output. |
| easing_mode | COMBO | linear | Easing curve applied when selecting intermediate frames between key frames. |
| include_last_frame | BOOLEAN | true | If True, the very last input frame is always included as a final key frame (with repeats), even if it doesn't land exactly on an interval boundary. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| key_frame_data | STRING | — |
| frame_indices_report | STRING | — |