---
name: frame-chaining
description: Use whenever the inferred intent is a continuous tracking shot or a long single-take video built from chained clips, including character-following journeys ("the character walks from room to room", "follow the figure across the city"), or an AI transition between two known frames (a first-to-last-frame clip from a start image to an end image, seamless loops from one image, chains of transitions A→B→C). Frame chaining: extract last frame → feed as next input → repeat → stitch. Covers workflow modes (all-at-once vs step-by-step), prompting rules, aspect ratio discipline, last-frame quality control, stitching, character continuity (original reference on every clip through reference-to-video, the handoff frame as an extra reference only, locked character description string, locomotion-through-space rule, the rear-facing danger, corrective stills), the morphing problem and visual bridges, and prompting cheat sheets for style/audio/camera.
category: video
---

# Frame Chaining

> **Scope (prompt fidelity).** This technique is for prompts you author, or when the user asks for help with a prompt. A user-written brief follows the always-on PROMPT FIDELITY rule.

AI video models generate 5–15 second clips. Frame chaining turns them into one long continuous shot:

1. Generate a short clip from a starting image
2. Extract its **last frame**
3. Use that frame as the **starting image** for the next clip
4. Repeat until the video is long enough
5. Stitch all clips together

The last frame of clip N equals the first frame of clip N+1, so the seam shows no visual jump.

---

## The Core Workflow

### Step 0: Analyze the Starting Input

Check the starting image's subject, possible motion, lighting and aspect ratio before generating. Confirm the intent: **one continuous shot** unless the user wants cuts between scenes.

When the user says where the new scene starts inside an existing clip, the last frame is not the default. Find that moment: sample stills around it (one `spiral/ffmpeg` run per still, for example `ffmpeg -ss 12.5 -i {in0} -frames:v 1 still.png` for the frame at 12.5 s), ask media understanding one question if needed, and show the chosen still with its timestamp. Start the paid video only after the user confirms that frame.

### Step 0.5: Ask — All at Once or Step by Step?

Before generating ANY video, ask the user how they want to drive the chain:

| Mode             | How it works                                                                                       | Best for                                                          |
| ---------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| **All at once**  | Generate every clip in sequence without pausing. Show the stitched result at the end.              | Users who trust the plan and want speed                           |
| **Step by step** | Generate one clip → show it → extract last frame → show frame → ask "Happy? Continue?" → next clip | Users who want control over character consistency and story beats |

Both modes are sequential (see "Sequential Only").

### Step 1: Generate the First Clip

- Feed the starting image to a video model
- Prompt for **continuous, single-take camera behavior** — no cuts, no jumps, no teleporting
- Keep the duration moderate (5-10s is a good starting chunk)
- Match the starting image's aspect ratio (see "Aspect Ratio Discipline")

### Step 2: Extract and Inspect the Last Frame

Pull the final frame with `spiral/ffmpeg` (`ffmpeg -i {in0} -update 1 last.png` keeps the last decoded frame) and run the checks in "Last Frame Quality Control" before using it.

### Step 3: Chain — Feed Last Frame as Next Input

- Use the extracted last frame as the starting image for the next clip. On a character chain, pass it as an extra reference next to the original character reference instead (see "Character Continuity in Chains")
- The prompt continues the same shot (same camera style, lighting, world) and describes what happens NEXT, not what already happened

### Step 4: Repeat, Then Stitch

Repeat generate → extract → generate until the target length, then normalize and stitch (see "Stitching the Final Video").

---

## Model Selection for Frame Chaining

- **Chains that follow a character use reference-to-video, not image-to-video.** Follow the `video-generation-rules` rule "Same character across multiple video segments": pass the original character reference to every clip, and add the extracted last frame only as an extra continuity reference. See "Character Continuity in Chains" below.
- Chains without a recurring character (landscapes, objects, abstract journeys) use **image-to-video**, feeding the last frame as the start image each time
- Prefer models that produce clean, stable last frames (some produce blurry or artifact-heavy endings)

**Stick to ONE model for the entire chain.** Different models render the same scene differently, and the style shift shows at every seam.

---

## Prompting Rules for Frame Chaining

### The Prompt Format

Structure prompts as `<medium> of <subject> in <style>, <texture>`. Examples of `<medium>`: cinematic video, documentary handheld video, glossy commercial video, analog film video.

### Continuity

Every prompt in a chain keeps the same camera style, lighting direction, color temperature, lens character (e.g. shallow DOF) and world rules (no objects appearing or disappearing between clips).

Every chain prompt includes:

- **Camera movement** — direction, speed, lens feel, stabilization, framing
- **Lighting** — direction, softness, color temperature
- **Action** — micro-actions, environmental and secondary motion (wind, particles)
- **Materials** — texture, realism cues, grain/noise if desired
- **Continuity constraints** — always include "single take", "no cuts", "no time jumps", "no teleporting". Without them, some models introduce internal cuts within a clip

### When the Chain Follows a Character: the Locomotion Rule

If the chain follows a character (a person, creature, mascot — anything with identity that must persist across clips), every clip must have **locomotion** — the character must be physically **moving through space**: walking from room to room, crossing a threshold, approaching something. Clips where the character just stands in one place performing a static action (making coffee at the counter, sitting at a desk working) feel disconnected from the chain — the camera has nothing to follow and the seam point looks like a hard cut.

✅ Good: "walks out of the bathroom, down the hallway, turns into the kitchen"
✅ Good: "approaches front door, opens it, steps out onto street"
❌ Bad: "stands at counter making coffee" — static, no locomotion

Even scenes anchored on a task (making coffee, brushing teeth) should begin or end with the character **moving to or from** the location.

### Plan the Arc and Evolve Prompts Gradually

Plan the full arc before generating, so the chain does not wander. Change the prompt **gradually** across clips to create a sense of journey:

| Clip   | Prompt Focus                                                                    |
| ------ | ------------------------------------------------------------------------------- |
| Clip 1 | Establish the scene — introduce subject, environment, camera style              |
| Clip 2 | Continue + add subtle change — camera starts to orbit, subject begins an action |
| Clip 3 | Develop — more motion, reveal new parts of the environment                      |
| Clip 4 | Climax or payoff — arrive somewhere, reveal something, complete an action       |

**Don't** copy-paste the same prompt for every clip; the video stagnates. **Don't** make drastic changes between consecutive clips: a slow dolly-in can't suddenly become a fast whip pan without breaking the single-take illusion.

---

## Aspect Ratio Discipline

Every clip in the chain uses the starting image's aspect ratio. Mixed ratios create visible jumps and distortion at seams. If the starting image's ratio is unknown, check it before generating.

When the requested ratio differs from what a model offers, pick a model whose schema exposes that ratio and set it on the call. Never generate another ratio and crop it afterwards: center-cropping 2:3 to 9:16 loses framing and resolution.

---

## Sequential Only

Frame chaining is **strictly sequential**, even in all-at-once mode: clip N+1's starting frame does not exist until clip N finishes. Never parallelize clip generation. Budget time accordingly: a 60-second video at 10s per clip is 6 sequential generations.

Quality degrades over very long chains (20+ clips) as small errors compound. For videos over about 2 minutes, consider sections with intentional cuts rather than one infinite take.

---

## Stitching the Final Video

### Normalization (Do This First)

Before stitching, all clips must have identical:

- **Resolution** — same width × height (e.g. 720×1280 for all clips)
- **Frame rate** — same fps (30fps is standard)
- **Pixel format** — same encoding (yuv420p)
- **Audio format** — same sample rate and channels (48000Hz, stereo) OR strip all audio if you're adding music/VO later

Then concatenate in order.

### Audio Handling

1. **Preserve native audio** — if all clips have audio from the same model, just concatenate. Subtle discontinuities at seams are usually acceptable.
2. **Strip all audio, add music later** — cleanest. Stitch video-only, then layer one continuous music track on top.
3. **Mix both** — keep native audio as ambient bed, add music on top at low volume (0.10-0.15).

### MJPEG Warning

Some video models output MJPEG, which won't stitch with H.264 clips. Transcode each MJPEG clip to H.264 with `spiral/ffmpeg` before stitching:

```
ffmpeg -i {in0} -vcodec libx264 -acodec aac -pix_fmt yuv420p -preset fast output.mp4
```

---

## Last Frame Quality Control

A bad last frame cascades into every later clip. Check for:

| Issue                      | What Happens If You Ignore It                 | Fix                                                         |
| -------------------------- | --------------------------------------------- | ----------------------------------------------------------- |
| Motion blur on last frame  | Next clip starts blurry, never recovers       | Regenerate clip or extract a frame from 0.5s before the end |
| Artifact / glitch          | Artifact gets baked into all subsequent clips | Regenerate clip                                             |
| Composition drift          | Subject slowly moves off-center across clips  | Adjust prompt to re-center, or pick a better last frame     |
| Color shift                | Lighting gradually changes across the chain   | Add explicit color/lighting anchors in every prompt         |
| Subject changed appearance | Character's outfit or features shifted        | Add "consistent appearance throughout" to prompts           |

---

## Character Continuity in Chains

These disciplines apply only when the chain follows a character (person, creature, mascot — anything with persistent identity). Small drifts in face, body, outfit and proportions compound clip after clip.

### The Original Reference Goes Into Every Clip

Identity must come from the original character reference on every clip, never from the previous clip alone. A raw last frame carries whatever drift the last clip introduced. If the face is hidden in it, the next clip invents a new one.

- Generate every clip with a reference-to-video model (pick it from `model-recommendations`, following the `video-generation-rules` rule "Same character across multiple video segments")
- Pass the original reference image (the user's upload or the approved character sheet) on every call
- Add the inspected last frame, or a better frame just before it, as an extra reference for pose, place, and lighting continuity
- Set the chain's aspect ratio on each call — reference-to-video composes a new frame rather than animating the reference as its canvas
- The seams are less pixel-identical than start-frame chaining. Bridge them with the matching pose and camera prompt below, or a short crossfade at stitch time. A consistent face matters more than a perfect seam
- Plan each join: end every part on a settled, front-facing hand-off pose (prompt it, or set it as the end frame) and start the next part from it. Before delivery, measure each join against the clip's own neighbouring frames: extract the frames on both sides of it and compare them. Regenerate a jumping part only when the approved plan already includes that retry; otherwise report the broken join first, with the cost of fixing it, and let the user decide

### The Locked Character Description String

Before generating any clip, write a **single locked character description** that you will paste into every clip prompt **verbatim**. Do not paraphrase or shorten it between clips. Consistency depends on exact repetition — a synonym in clip 3 ("dark eyes" instead of "large glossy dark oval eyes") is enough to drift the rendering.

**Example:**

> "a handmade papier-mache skeletal humanoid creature with a long angular beak head, large glossy dark oval eyes, rough brown cardboard-strip texture, exposed rib-like chest construction, long spindly arms and legs with clawed fingers"

### The Mandatory Character Check After Every Extraction

On a character chain, the technical last-frame check is not enough. After every extraction, also ask:

1. **Is the character still the same?** Compare to the starting still: same head shape, eyes, texture, proportions, outfit and distinguishing features (beak, markings, clothing details)?
2. **Is the character facing AWAY from camera?** See the rear-facing danger below.
3. **Is the environment coherent?** Does it match where the clip was supposed to end?

If the character has visibly drifted, **do NOT continue the chain from this frame** — the next clip compounds the drift. Regenerate the clip with a more explicit character description, or hard-reset with a corrective still (below).

### The Rear-Facing Danger — the #1 Failure Mode

When the character is seen **from behind** in the last frame, the model has no face/head reference to maintain. On the next generation it will **invent a completely new character** — different head, different proportions, different texture, lost distinguishing features.

**How to avoid it:**

- Prompt camera angles that keep the character's **face or distinctive features visible**, at least in profile
- If a following/tracking shot is needed (camera behind character), make sure the clip **ENDS** with the character turning, entering a room, or being seen from the side
- When the last frame IS rear-facing, include even more detail in the next prompt's character description, and add an explicit instruction: "same character as in this frame, identical [material/construction] and proportions — do NOT reimagine the character"
- When that fails, generate a **corrective still** (below) instead of using the raw last frame

### Corrective Stills — Hard-Reset the Character When Drift Compounds

A **corrective still** is a generated image that resets the character's appearance. Use one when the raw last frame is unusable for continuation (rear-facing without recovery, character visibly changed, environment doesn't match where the next clip starts). Better prompting alone rarely fixes drift once the character has changed.

**How to generate one** (with an image model):

- Include the full locked character description string verbatim
- Include the original character reference as an image reference for visual anchor (field name varies by image model — confirm it when you read its input schema)
- Describe the character in the **new location** from a front or three-quarter angle (never rear)
- Match the aspect ratio, lighting, and style of the existing chain
- Pass this corrective still as the next clip's extra continuity reference, alongside the original character reference

The seam at a corrective still is slightly less seamless, but one small hiccup beats a character that looks different by clip 4.

---

## Prompting Cheat Sheet

Starting points to combine (style line + audio template + camera template), then adapt to the clip.

### Style Lines by Genre

| Genre                      | Style line                                                                                                                                                                                  |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Jan Švankmajer stop-motion | "Stop motion animation in the style of Jan Svankmajer — handcrafted tactile stop-motion, every movement a hard discrete frame-by-frame jerk, no smoothing, pure puppet animation aesthetic" |
| 1990s film stock           | "Cinematic video, 35mm Kodachrome 200 film stock, [year and place]"                                                                                                                         |
| British TV stop-motion     | "1970s British stop motion television animation — handmade puppet, warm lo-fi grain, slightly overexposed, Bagpuss aesthetic"                                                               |
| Documentary                | "Handheld documentary footage, observational camera, natural available light, slight camera float"                                                                                          |
| Horror                     | "Found footage horror, low-light, desaturated, shaky handheld, VHS tracking artifacts"                                                                                                      |
| Fantasy                    | "Cinematic fantasy, painterly lighting, golden hour, epic scale, practical effects aesthetic"                                                                                               |

### Audio Description Templates

| Setting               | Audio template                                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Stop-motion character | "Audio: papier-mache creak on every movement, cardboard joints clicking, [specific ambient sounds for environment]" |
| Cinematic street      | "Audio: ambient crowd noise, distant traffic, no music"                                                             |
| Domestic interior     | "Audio: [specific room sounds — kettle, keyboard, clock tick, etc.], quiet domestic ambience"                       |
| Horror interior       | "Audio: distant creaking, wind through gaps, dripping water, no music"                                              |
| Nature/outdoor        | "Audio: birdsong, wind through trees, distant water, footsteps on [surface]"                                        |

### Camera Movement Templates

| Type          | Template                                                                                       |
| ------------- | ---------------------------------------------------------------------------------------------- |
| Following     | "Camera tracks directly behind at [low/medium/high] angle, following the character's progress" |
| Observational | "Camera holds steady at [room] doorway POV, watching"                                          |
| Reveal        | "Camera follows through doorway, revealing [new space]"                                        |
| Push-in       | "Slow smooth push toward character as they approach"                                           |
| Over-shoulder | "Over-the-shoulder tracking shot, slightly above character's head height"                      |
| Side tracking | "Camera moves alongside character at walking pace, medium shot framing"                        |

⚠️ The "Following" template leaves the character rear-facing at clip end — pair it with an action that turns the character at the end, or plan a corrective still after the clip.

---

## Optional: Music on the Final Stitched Video

If the user wants music on top of the stitched chain:

1. Pick a music model from the `model-recommendations` skill ("Music generation"). Describe era, instruments, mood, vibe. Duration = video length + a small buffer (~2–3s) so the fade-out has room.
2. Preview the audio with the user before mixing.
3. Mix the music onto the stitched video. Mix intent:

| Layer              | Intent                                                            | Calibration (0–1 scale) |
| ------------------ | ----------------------------------------------------------------- | ----------------------- |
| Music              | Roughly equal share with native ambient (no VO competing for it)  | ~0.5                    |
| Native chain audio | Roughly equal share with music (preserves ambience and footsteps) | ~0.5                    |

These ratios are higher for music than the standard character-films mix because there's **no voiceover** here — just native ambient audio sharing space with music. Adjust per user preference. Calibration assumes 0–1 mix-ratio fields; confirm field names + value scale via the mix tool's schema and translate the intent.

For fade-out on the music file (so the chain doesn't end with an abrupt music cut), apply the fade to the **music file only**, never to the final mixed video — fading the final video fades the ambient SFX too. See the `character-films` skill's Phase 9 fade rule and ffmpeg `afade` recipe.

---

## Chaining Between Two Known Endpoints (AI Transitions)

Use this when the user has a **specific starting image** and a **specific ending image** and wants generated footage that travels from one to the other: a transition between two frames, a seamless loop, or a chain of transitions A→B→C. This is new footage, unlike a crossfade or wipe that blends existing clips. A plain crossfade or dissolve between two existing clips needs no generation: merge them with a fade or dissolve (the **media-editing** Skill). Keep AI transitions for dramatic scene changes, impossible camera moves and magic transformations, and test ONE transition before committing to a chain.

**The model must support first-to-last frame.** Ordinary image-to-video animates forward from one image with no control over the end; a first-to-last-frame model fixes both endpoints. Not every video model has it: a start-frame-only model wastes a paid run on unusable output. Pick the model from **model-recommendations**, confirm in its input schema that it takes both a start and an end frame, and pass BOTH images. First-to-last-frame usually costs more than plain image-to-video, and a chain of 5 transitions is 5 video runs.

**Classify the visual distance first**; it drives the model and the prompt:

- **Level 1, minimal** — same scene, tiny change (eyes open → closed). Almost any first-to-last-frame model handles it.
- **Level 2, moderate** — same context, large change (messy → clean room, winter → summer, boxed → unboxed). Fixed elements must stay in place; results vary by model.
- **Level 3, maximum** — unrelated scenes (coral reef → desert highway). Only the best models manage it, and this is where the morphing problem appears. Do not over-ambition a Level 3 into a short clip.

**The morphing problem.** Between very different images, the middle of the clip (about 40–60 % through) is halfway between both and committed to neither: without guidance the model morphs linearly into melting, blobby shapes and faces dissolving into landscapes. Two fixes, used together for Level 3:

- **A visual bridge** in the prompt: a neutral zone both scenes connect to — darkness, bright white light, fog or smoke, an extreme close-up texture, motion blur (a whip pan), or particles ("the scene dissolves into floating particles that reform into …").
- **Smart image pairing**: design the two frames to share anchors — a horizon line (ocean → desert horizon), a dominant color (blue water → blue sky), a shape (round tunnel → round moon), a composition (centered subject in both), a lighting direction. The more they share, the less the model morphs.

**Prompt the journey**, not the endpoints: start → how the transformation happens → end. The more specific the mechanism, the less the model falls back to a linear morph.

| Style                  | Prompt language                                                                                 | Best for                      |
| ---------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------- |
| Whip pan               | "Extreme fast horizontal whip, heavy motion blur, snapping to new scene"                        | Energetic, fast-paced         |
| Theatrical rebuild     | "Scene disassembles and reassembles like a stage set change"                                    | Playful, theatrical           |
| Mechanical transformer | "Environment folds and reconfigures mechanically, panels rotating, pieces locking into place"   | Tech, sci-fi, product reveals |
| Dolly zoom             | "Camera dollies through space while zooming, distorting perspective into new environment"       | Disorienting, psychological   |
| Match cut              | "Camera movement continues seamlessly into new scene at same angle and speed"                   | Cinematic, narrative          |
| Smash cut              | "Instantaneous hard cut energy, no transition — slam into new scene"                            | Comedy, shock, horror         |
| Morph / dissolve       | "Environment morphs and dissolves, textures bleeding between scenes"                            | Dreamy, surreal               |
| Simulation glitch      | "Reality pixelates and shatters, reforming as new environment"                                  | Tech, gaming                  |
| Darkness bridge        | "Camera pushes into deep shadow, passes through darkness, emerges into bright new scene"        | Level 3                       |
| Light bridge           | "Blinding light fills the frame, then fades to reveal new environment"                          | Dramatic reveals              |
| Fog bridge             | "Thick fog rolls in obscuring everything, then clears to show new scene"                        | Mystery, atmosphere           |
| Texture bridge         | "Camera pushes into surface grain/texture until it fills frame, pulls back to reveal new scene" | Abstract, material-focused    |

**Both frames share one aspect ratio and resolution**, and the video uses exactly that ratio (Aspect Ratio Discipline above): never default to 16:9. If the model generates audio, the transition's audio should flow smoothly too.

**Loops.** Pass one image as both the first and the last frame: the clip departs from and returns to the same state, so it repeats with no seam. Keep the motion simple and cyclical (breathing, waves, flames, swaying trees); avoid actions that would have to undo themselves (a door that opens must close). Watch 3+ loops in a row: any mismatch shows on repeat.

**Chains A→B→C→D.** Each transition's last frame must exactly match the next one's first frame. Models drift from the target end frame, so extract each generated clip's actual last frame (Step 2 above) and use it as the next start: A→B, extract B_actual, B_actual→C, extract C_actual, C_actual→D. This is sequential: each step needs the previous output. When one transition is too short or its morph too extreme, break it into stages with generated intermediate images (A → M1 → M2 → B), each a shorter, easier transition.

**Stitching transitions.** Normalize every clip (Stitching the Final Video above), and drop the duplicate seam frame: the last frame of one clip and the first of the next are the same image, so trim the first frame of clips 2..N (`trim=start_frame=1,setpts=PTS-STARTPTS`) inside the merge command (the **media-editing** Skill, "Merge video clips"). When some clips have audio and others do not, give the silent ones silence or strip audio from all before joining.

---

## Tracking Long Chains

For chains longer than 3-4 clips, track each clip's number, duration and asset name, every extracted last frame (e.g. `last-frame-clip-03`), the stitching order and normalization, the audio plan (decide before stitching), and clips flagged for regeneration.
