Skip to content

A Claude Code plugin that turns a story into a finished anime

Ruby

improve pipeline - add examples

Francesco 'makevoid' Canessaaa1c0800ca57
diff --git a/skills/make-an-anime/SKILL.md b/skills/make-an-anime/SKILL.md
index c910d21..a3f832a 100644
--- a/skills/make-an-anime/SKILL.md
+++ b/skills/make-an-anime/SKILL.md
@@ -1,6 +1,6 @@
---
name: make-an-anime
-description: Create and revise anime, from a 12-second battle scene to full episodes and narrated documentaries, from a story and optional character reference photos. Character and location sheets with GPT Image 2.5 Sunburst xhigh, cinematic camera-directed shots animated with MiniMax H3 Max, green-screen layered composites over animated backgrounds, a distinct ElevenLabs Eleven v4 voice per character with lip-sync, ElevenLabs Music v2.5 scores, p5 screens/titles/subtitles, SFX and Swift VFX. Use for whole episodes, pilots, single scenes, or revisions to their cast, voices, shots, sound and effects.
+description: Create and revise anime, from a 12-second battle scene to full episodes and narrated documentaries, from a story and optional character reference photos. Character and location sheets with GPT Image 2.5 Sunburst xhigh, cinematic camera-directed shots animated with MiniMax H3 Max with characters and world painted together, manga paper-cut panels, a distinct ElevenLabs Eleven v4 voice per character with lip-sync, ElevenLabs Music v2.5 scores, p5 screens/titles/subtitles, SFX and Swift VFX. Use for whole episodes, pilots, single scenes, or revisions to their cast, voices, shots, sound and effects.
license: MIT
compatibility: Designed for Claude Code. Requires Ruby 3.2+, Bundler, web search and sub-agent tools. Media tasks require FFmpeg, ImageMagick, Python 3, Node.js 22+ and Chrome. Swift VFX requires macOS 14+ and Swift 5.9+. Fal generation requires the plugin's sensitive FAL_AI_API_KEY option or that environment variable for local development.
---
@@ -9,6 +9,8 @@ compatibility: Designed for Claude Code. Requires Ruby 3.2+, Bundler, web search
Turn a story into a finished, voiced, scored anime: a cold open that hooks, characters who stay on-model (and recognisably the real people, when reference photos are supplied), shots that are composed and camera-directed like a good TV anime, voices that belong to each character, and a score that carries the emotion. Default to cinematic restraint with moments of shounen energy: hold on faces, let pauses breathe, then hit cuts and camera moves on the beats. A different tone in the user's brief overrides this default.
+**The footage must look real.** Light, contact, motion and camera agree across the whole frame, or it looks pasted together and AI-generated. Action is never on green screen: paint the character and the world in one H3 take, with one runner per shot and a camera that travels. Read [believable-motion.md](references/believable-motion.md) before planning any shot.
+
The art direction comes from the story, the brief and the references. Write it down once as a style bible (`config/style.md`) and reuse it, unchanged, in every image and H3 prompt through `{{STYLE}}`.
## Execution contract
@@ -47,7 +49,7 @@ Summarize the cast, look, voices, the opening hook, shot list and costs in chat.
## 3. Produce
-Read [production.md](references/production.md), [prompts.md](references/prompts.md) (style, sheets, **camera language**) and [animation-audio-vfx.md](references/animation-audio-vfx.md). Fetch current schemas with `openapi:fetch`; never silently downgrade or substitute a model.
+Read [believable-motion.md](references/believable-motion.md), [production.md](references/production.md), [prompts.md](references/prompts.md) (style, sheets, **camera language**) and [animation-audio-vfx.md](references/animation-audio-vfx.md). Fetch current schemas with `openapi:fetch`; never silently downgrade or substitute a model.
Order of work, each step reviewed before the next:
@@ -55,15 +57,15 @@ Order of work, each step reviewed before the next:
2. **Voices** (`Steps::Dialogue`): cast one distinct ElevenLabs Eleven v4 voice per character in `config/cast.yml`; generate the scene's lines; `review:dialogue` verifies each line with Whisper. Line timings set the shot lengths, so do this before animating, and run `dialogue:timeline` after any voice or shot change.
3. **Score** (`Steps::Music` with `03_score.json`): ElevenLabs Music v2.5 composition plan whose chunks follow the scene's beats, instrumental, exactly scene length. Then `Steps::Mix` ducks it under the dialogue.
4. **Keyframes** (`Steps::Keyframes`): one composed first frame per shot, edited from the cast/location sheets (`base: false`, `refs: [...]`).
-5. **Shots** (`Steps::Shots`): H3 Max animates each keyframe at **768P** by default, with the shot's camera move written as its own `camera:` direction and the speaking character's mouth track as target audio. Still holds and solid inserts cost nothing. `review:camera` measures the move each shot actually made.
-6. **Layers, when the shot needs them** (`Steps::Clips`): a character performed alone on flat green, keyed to a PNG sequence and moved in p5 over an animated background plate. Painted full-frame H3 shots are the default; read [layered-scenes.md](references/layered-scenes.md) for when layers win and how to do them.
+5. **Shots** (`Steps::Shots`): H3 Max animates each keyframe at **768P** by default, with the shot's camera move written as its own `camera:` direction and the speaking character's mouth track as target audio. Still holds and solid inserts cost nothing. `review:camera` measures the move each shot actually made, and `review:believable` checks the prompts and takes for action on green and treadmill runs (`gen:clips` and `gen:shots` refuse the written failures before any paid call).
+6. **Panels and layers, only for people who stay put** (`Steps::Clips`): two people far apart talk on one screen through painted panels with a paper cut (`key: none`, `Anim.paperCutPanels`), see [believable-motion.md](references/believable-motion.md). A keyed green performance is the last resort, for a still figure with no action; read [layered-scenes.md](references/layered-scenes.md) first.
7. **Overlay** (`Steps::Overlay`): p5 draws screens, UI, title cards, subtitles and transitions over the plate, using `tools/p5/lib/screens.js` (code editor, typing, subtitles, place cards) and `tools/p5/lib/battle.js` (title slam, speed lines, impacts, camera roll). Then `sfx:gen`/`sfx:mix` and optional Swift VFX.
Delegate production to sub-agents in waves (**2 assets first → 3–4 → 4–8 → 6–10 repeatedly**) with `work:next`, `work:log`, `work:watch` and `work:accept`, as described in [production.md](references/production.md). A short pilot can run serially; say so. Schedule the opening and the emotional peak early. Never let concurrent workers edit shared config, cast or identity sheets.
## 4. Review and deliver
-Watch every shot at normal speed with sound. Reject a shot whose face drifts off-model, whose hands or anatomy break, whose camera does something other than the directed move, whose background morphs, or that invents text, people or props. For dialogue, check that the speaking character's mouth moves on their words and rests on others' lines; `target_audio_url` pins the soundtrack but is **not proof of lip-sync**. Regenerate within the retry allowance and report what remains imperfect.
+Watch every shot at normal speed with sound. Run `review:believable`, then check the by-eye list in [believable-motion.md](references/believable-motion.md). Reject a shot that looks composited, whose runner stays in place while the world stands still, whose face drifts off-model, whose hands or anatomy break, whose camera does something other than the directed move, whose background morphs, or that invents text, people or props. For dialogue, check that the speaking character's mouth moves on their words and rests on others' lines; `target_audio_url` pins the soundtrack but is **not proof of lip-sync**. Regenerate within the retry allowance and report what remains imperfect.
A multi-scene episode has its own workflow: read [full-episode.md](references/full-episode.md) (playing order, loudness across scenes, seams, retakes). Assemble scenes contiguously (`episode:preview`, `media:concat`), check the frame count, mix SFX, and deliver the episode video, a clean version without SFX/VFX, the character sheets, the cast/voice table, the plan, research, manifests and a concise summary of revisions and unresolved issues. Completion means every planned scene of the requested part is assembled, reviewed and delivered.
diff --git a/skills/make-an-anime/assets/plan-template.md b/skills/make-an-anime/assets/plan-template.md
index 68523f7..baa8511 100644
--- a/skills/make-an-anime/assets/plan-template.md
+++ b/skills/make-an-anime/assets/plan-template.md
@@ -30,6 +30,8 @@ Locations: id, description, light, full prompt, which scenes use it.
| Run | Frames [start, end) | Beat | Shot | Size/angle | Camera move (from → to, speed, timing) | Source (H3 / still / colour) | Speaker / audio track | Lines (at, text) | p5 (screens, titles, subtitles) | SFX | Dependencies |
|---|---|---|---|---|---|---|---|---|---|---|---|
+For every action shot, answer in the plan: is the character painted with the world in one take (never keyed)? If someone runs, is there one runner and a camera that travels, and what passes behind them? For two people talking far apart, use paper-cut panels. See `references/believable-motion.md`.
+
For every shot: the keyframe prompt and refs, the H3 prompt, the `camera:` block, seconds, audio track, and acceptance (on-model faces, camera did the directed move, mouth on the right lines, no invented text).
## Dialogue and score
@@ -42,4 +44,4 @@ First 2 pilot assets (usually the protagonist's sheet and one other), then 3–4
## Review and delivery
-Likeness board, voice table, per-shot playback review, lip-sync check on talking shots, camera check, frame count, soundtrack continuity, SFX levels, delivery paths and known issues.
+Likeness board, voice table, `review:believable` with the by-eye list, per-shot playback review, lip-sync check on talking shots, camera check, frame count, soundtrack continuity, SFX levels, delivery paths and known issues.
diff --git a/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_clips.yml b/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_clips.yml
index ae8c699..0092ad9 100644
--- a/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_clips.yml
+++ b/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_clips.yml
@@ -1,6 +1,8 @@
+# NOT a model for action: see references/believable-motion.md.
# Green-screen performances: H3 with a locked camera, keyed to transparent PNG sequences. audio: <cast id> pins that
# character's mouth track, audio_at: the scene second the clip starts at, so frame i is scene time audio_at + i/24.
- name: kaen
+ believable: kept only to test keying. Punching on green looks fake, so do not copy this; see references/believable-motion.md
image: kaen-green
seconds: 5
frames: 120
diff --git a/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_shots.yml b/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_shots.yml
index c9d0a8a..d58a901 100644
--- a/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_shots.yml
+++ b/skills/make-an-anime/examples/shonen-battle/prompts/shonen-s01/04_shots.yml
@@ -5,6 +5,7 @@
# The layered section's background: H3 animates the empty arena, and `roll` turns the plate locally. p5 draws the two
# keyed fighters over it inside Anim.withRoll, so they turn with it (05_overlay.js).
- name: composite-plate
+ believable: clouds race across the sky, and nobody runs in this empty plate
image: arena-plate
frames: 120
roll: [-9, 9]
diff --git a/skills/make-an-anime/examples/shonen-battle/story.md b/skills/make-an-anime/examples/shonen-battle/story.md
index 9f41e34..c81386b 100644
--- a/skills/make-an-anime/examples/shonen-battle/story.md
+++ b/skills/make-an-anime/examples/shonen-battle/story.md
@@ -6,6 +6,8 @@ Kaen, a flame fighter, and Arashi, a storm fighter, meet on a broken arena float
fought before and neither will back down. She tells him it ends here, he answers, they rush each other and the shock
of the first clash splits the sky. In the last five seconds the camera whips around them as they trade finishing moves.
+This example tests the toolkit's keying. Its layered fight is not a model to copy: action on green screen looks fake (see `references/believable-motion.md`).
+
- 0–2 s: title card "EMBER × TEMPEST".
- 2–7 s: LAYERED COMPOSITE. Each fighter is animated alone on green screen with H3, keyed, and moved by p5 over an
animated H3 background plate. The camera rolls and circles.
diff --git a/skills/make-an-anime/references/animation-audio-vfx.md b/skills/make-an-anime/references/animation-audio-vfx.md
index df466ef..fc38dac 100644
--- a/skills/make-an-anime/references/animation-audio-vfx.md
+++ b/skills/make-an-anime/references/animation-audio-vfx.md
@@ -2,7 +2,7 @@
## Separation of work
-H3 supplies expressive, self-contained characters on chroma green; p5 supplies the world around them: exact timing, camera movement, environments, props, text, diagrams and layer order. A full-frame H3 plate is a justified exception, not an equal option (see "Self-contained characters" in [prompts.md](prompts.md)). Python removes backgrounds, measures audio and composites sound. Swift applies final frame-cued camera, light and signal effects. Ruby services own all execution and manifests.
+H3 supplies the characters and their world together, in one full-frame take; p5 supplies exact timing, panels, text, diagrams and layer order on top. Action is never keyed (see [believable-motion.md](believable-motion.md)). Keyed characters are for explainers and paper-style pieces with no realistic world, and for a still figure as a last resort. Python removes backgrounds, measures audio and composites sound. Swift applies final frame-cued camera, light and signal effects. Ruby services own all execution and manifests.
## p5 scenes and overlays
diff --git a/skills/make-an-anime/references/believable-motion.md b/skills/make-an-anime/references/believable-motion.md
new file mode 100644
index 0000000..4d4bda3
--- /dev/null
+++ b/skills/make-an-anime/references/believable-motion.md
@@ -0,0 +1,92 @@
+# Believable footage
+
+Footage has to look like it was really shot and drawn as one piece. "Realistic" here means physically believable, not photoreal: the style bible still sets the anime look. Light, contact, motion and camera must agree across the whole frame. When they don't, the result looks pasted together and AI-generated, however good each part is.
+
+Check every shot against this page: when you plan it, before you pay for it, and when you review it.
+
+## The rules
+
+1. **Action is never on green screen.** A keyed figure has no ground contact, no shared light and no shared camera, so running, punching, falling or jumping on green looks ridiculous. Generate the character and the world in the same H3 take.
+2. **One runner per shot, with a camera that travels.** Show one person running with the world moving behind them, and let the cut bring people together. Two people running at each other in one wide shot comes out as two treadmills, even with no key.
+3. **Green screen is only for someone who stays put.** It can carry a calm line or a held pose, with the figure cropped by the frame so no feet show. Even then, prefer painted panels (below).
+4. **Paint people into the world.** Keyframes say "one painted image with the character and the world drawn together", name the light direction on the body, and put out-of-focus grass or props in front of the figure. Foreground overlap sells the depth.
+5. **Effects must not sit on top of the painting.** Glows, rings, auras, speed lines and embers read as pasted on. Sell a blow with the cut, a short jolt, a brief flash and the sound.
+6. **Keep the camera partial.** A partial arc reads as a camera operator. A full spin reads as a stunt.
+
+## Two people talking who are far apart: the paper cut
+
+To put them on one screen, use a manga page instead of compositing them into one background.
+
+1. Make one keyframe per person, each with their own copy of the location, with the subject in their side of the frame. Use the same location sheet for both, and tell each which side the sun is on.
+2. Animate each as a full-frame take in `04_clips.yml` with `key: none`, a locked camera, `audio:` and `audio_at:`. The wind, water and clouds move in the same generation.
+3. Give the shot under them `color: "#000000"` in `04_shots.yml`, and draw the page in the overlay:
+
+ ```js
+ Anim.paperCutPanels(
+ () => this.left.draw(this.left.at(t), x1, y, h),
+ () => this.right.draw(this.right.at(t), x2, y, h),
+ { cut: [1040, 880], gutter: 26 }
+ );
+ Anim.subtitles(t, lines, { font, x: 470, skip: (l) => l.character !== "left-id" });
+ Anim.subtitles(t, lines, { font, x: 1450, skip: (l) => l.character !== "right-id" });
+ ```
+
+ Scale each panel a little so the person fills it, and keep raised hands clear of the cut. Place each subtitle under its speaker's panel.
+
+## A run that works
+
+The keyframe already looks like a moving camera: one person in side view, sharp, with the near grass smeared into horizontal streaks and the background softly streaked along the direction of travel.
+
+```yaml
+- name: charge
+ image: charge
+ frames: 36
+ seconds: 2.5
+ source_frames: 60 # about 1.7x, a real sprint cadence
+ retime: true
+ prompt: "... He sprints flat out from left to right ... He stays in the centre of the frame because the camera travels with him. The whole world rushes past behind him from right to left the entire time: the near grass whips through the foreground, the bushes and the path slide quickly past, the river and the bridge drift more slowly far behind, a strong layered parallax."
+ camera:
+ move: fast lateral tracking shot, the camera travels sideways alongside the runner at his exact speed, never stopping
+ to: the same side view of him, much further along the riverbank
+ timing: full speed from the first frame to the last
+```
+
+Name something large in the near background, such as bushes or a fence. It gives the eye something to see passing.
+
+## Detection
+
+`RUN=<run> ruby mv.rb review:believable` is local and free, and works before and after generating. Run it when the prompts are written and again after `gen:shots`.
+
+| Check | When | Result |
+|---|---|---|
+| Action words in a keyed clip's prompt | Before any paid call | `gen:clips` refuses |
+| A run whose camera does not travel | Before any paid call | `gen:shots` refuses |
+| Several runners in one shot | Before any paid call | `gen:shots` refuses |
+| The near ground of a run moves under 0.20 frame widths per second | After the take exists | Issue: retake with more camera travel |
+| A colour split (`rgb`) above 0.05 in the VFX cues | Before the render | Issue: it garbles the picture |
+| Keyed sprites, plate rolls, full turns, pasted-on effects | Any time | Warning: look at it |
+
+The measure uses only the near ground, because in a good tracking shot the sky and a far bridge barely move. Calibration on real H3 takes: the rejected two-man run scored 0.11, the tracked single runner 0.28, and static or dialogue shots 0.00–0.04. That is only two runs, so read the frame strip too. A locked shot of someone who really crosses the frame would fail this measure.
+
+Word matching can be wrong, as in "runs a hand through his hair". Then the item states why it is fine, and the review prints the reason:
+
+```yaml
+believable: no running, only a hand gesture
+```
+
+Use this only for a word that was misread, never to push real action through.
+
+**What the tools cannot catch:** a p5 sketch that slides a sprite across the frame, wrong light on a figure, floating feet, or a run where the ground moves but the legs look wrong. Those need your eyes.
+
+## Review by eye
+
+Watch at normal speed, then look at a dense frame board around every hit and cut. Sparse boards miss short glitches.
+
+- Do the feet land where the body travels, and does anyone run in place?
+- Does the light on each person match the sky and ground behind them?
+- Does anyone have an outline, a halo or a hard edge against the background?
+- Does each blow connect at contact, on the frame of its sound?
+- Does any glow, ring or line look stuck on top of the picture?
+- Look at the frames right after a flash. A bright effect can hide a broken frame in a sparse check.
+
+If any of these fails, the shot fails, however good the rest of it looks.
diff --git a/skills/make-an-anime/references/full-episode.md b/skills/make-an-anime/references/full-episode.md
index b4fe77e..d89b45d 100644
--- a/skills/make-an-anime/references/full-episode.md
+++ b/skills/make-an-anime/references/full-episode.md
@@ -19,6 +19,7 @@ RUN=ep01-s05 ruby mv.rb gen:mix # local
RUN=ep01-s05 ruby mv.rb gen:keyframes # paid
RUN=ep01-s05 ruby mv.rb gen:shots # paid
RUN=ep01-s05 ruby mv.rb review:camera # local: measured against directed camera, with frame strips
+RUN=ep01-s05 ruby mv.rb review:believable # local: action on green, treadmill runs, garbling VFX values
RUN=ep01-s05 ruby mv.rb gen:overlay # local for anime scenes
SFX=ep01-s05-sfx ruby mv.rb sfx:gen # paid, cached
SFX=ep01-s05-sfx ruby mv.rb sfx:mix # local
diff --git a/skills/make-an-anime/references/layered-scenes.md b/skills/make-an-anime/references/layered-scenes.md
index f3b1541..30701c4 100644
--- a/skills/make-an-anime/references/layered-scenes.md
+++ b/skills/make-an-anime/references/layered-scenes.md
@@ -1,13 +1,10 @@
# Layered scenes: green-screen characters over an animated background
-Painted full-frame H3 shots are the default: they are one pass, and light, depth and contact come free. A layered scene costs more clips and more review, and it earns that when you need something H3 will not do reliably in one take:
+**Do not use this for action.** A keyed fighter has no ground contact, no shared light and no shared camera, so a run, a punch or a fall looks ridiculous, and `gen:clips` refuses it. Read [believable-motion.md](believable-motion.md) first.
-- two characters who must each keep their face and act exactly on cue;
-- precise placement and timing of a hit, locked to the score;
-- a camera or effect that must match frame-accurately across layers;
-- a character moved, scaled or reused freely in p5.
+Painted full-frame H3 shots are the default: they are one pass, and light, depth and contact come free. For two people talking far apart, painted panels with a paper cut are better than this recipe. Layers are the last resort, for someone who stays still and must act exactly on cue, cropped by the frame so no feet show.
-`examples/shonen-battle` is a complete worked example, with a 5 s layered section beside a 5 s full-H3 section for comparison. Start one with `init --project /absolute/project --example shonen-battle`.
+`examples/shonen-battle` shows the mechanics, but its layered section is what not to copy: its fighters punch and dash on green. It stays as a test of keying, and its items carry a `believable:` note saying so.
## The recipe
@@ -38,5 +35,5 @@ Painted full-frame H3 shots are the default: they are one pass, and light, depth
## Review
- Look at the key on light and dark: hair, hands, feet, spill. `RECUT=1 ONLY=<name> FORCE=1 gen:clips` re-keys a downloaded clip for free.
-- A sprite has no contact shadow, and it carries the light of its keyframe. Direct the light of the green keyframe to match the plate, and hide the ground contact with dust, speed lines or a low camera.
+- A sprite has no contact shadow, and it carries the light of its keyframe. Direct the light of the green keyframe to match the plate, and crop the figure so no ground contact shows. If it still looks pasted on, paint the shot instead.
- Check the mouth against the line at normal speed: `audio` pins the track but is not proof of lip-sync.
diff --git a/skills/make-an-anime/references/production.md b/skills/make-an-anime/references/production.md
index 5f10c74..1afcdd8 100644
--- a/skills/make-an-anime/references/production.md
+++ b/skills/make-an-anime/references/production.md
@@ -44,7 +44,7 @@ For the first pilot wave, each production worker generates one representative ke
## Review and advancement
-Inspect the assets and opening/peak playback. A contact sheet alone cannot prove acting or lipsync. Reject a character keyframe before animating it unless it shows one character in one pose, a flat chroma green background with no floor, shadow or spill on the character, the whole silhouette inside the frame with a margin, and a visual style and colour treatment consistent with the approved style bible, including its permitted shading and lighting variation. Reject an H3 clip whose camera moves, whose background changes or that adds props, people or text. Save `docs/reviews/<job>.md` with actual inspected paths, problems and decisions. Run relevant `review:*` tasks and retain their metrics. `JOB=... EVIDENCE=... work:accept` records coordinator acceptance. Failed jobs remain active; fix and review them before advancing. The program requires an evidence file but cannot judge its truthfulness or replace human/agent visual review.
+Inspect the assets and opening/peak playback. A contact sheet alone cannot prove acting or lipsync. Reject a character keyframe before animating it unless it shows one character in one pose, a flat chroma green background with no floor, shadow or spill on the character, the whole silhouette inside the frame with a margin, and a visual style and colour treatment consistent with the approved style bible, including its permitted shading and lighting variation. Reject an H3 clip whose camera moves, whose background changes or that adds props, people or text. Both of those apply to keyed clips only, which are never for action. Run `review:believable` and apply [believable-motion.md](believable-motion.md) to every shot. Save `docs/reviews/<job>.md` with actual inspected paths, problems and decisions. Run relevant `review:*` tasks and retain their metrics. `JOB=... EVIDENCE=... work:accept` records coordinator acceptance. Failed jobs remain active; fix and review them before advancing. The program requires an evidence file but cannot judge its truthfulness or replace human/agent visual review.
Use `docs/PROGRESS.md` for implementation status. Do not edit the approved PLAN.md just to log progress, since it invalidates approval. A changed character concept/scene direction belongs in a revised plan and user review. Approved routine pose fixes do not.
diff --git a/skills/make-an-anime/references/prompts.md b/skills/make-an-anime/references/prompts.md
index 81b8d0d..8065001 100644
--- a/skills/make-an-anime/references/prompts.md
+++ b/skills/make-an-anime/references/prompts.md
@@ -43,7 +43,7 @@ Name versions, never overwrite: a rejected sheet stays in its run for comparison
1. `{{STYLE}}`
2. Shot size and angle (e.g. "medium close-up, slightly low angle, 35mm feel"), subject placement in percent of frame and facing direction, eyeline.
3. The pose at the **first frame** of the action, expression, hands.
-4. Set, props and light sources with direction and colour; time of day.
+4. Set, props and light sources with direction and colour; time of day. Put the character in the world: say which side of the body the light falls on, and put something out of focus in front of them.
5. Space left for p5 elements (a subtitle band, a screen insert).
6. Exclusions: no text on screens or signs (screens show a soft blank glow), no extra people.
@@ -96,9 +96,13 @@ camera:
focus: shallow depth of field, background bookshelf softly blurred
```
+### Action shots
+
+Action is painted with its world in one take. Write "one painted image with the character and the world drawn together" in the keyframe, and name the light on the body. For a run, direct one runner, a camera that travels beside them, and what passes in the foreground and background. [believable-motion.md](believable-motion.md) has a worked example, and `review:believable` checks it.
+
### Sprite composites
-When several characters must be choreographed independently, or a performance is reused over different plates, animate each character alone on flat chroma green #00B140 with a locked camera (`Steps::Clips`, `key: green`) and composite them in p5 over a still plate; the camera is then a p5 transform of the whole composite. This is the exception for anime; painted full-frame shots are the default.
+Never for action: `gen:clips` refuses it. A keyed sprite is the last resort for a figure who stays still, on flat chroma green #00B140 with a locked camera (`Steps::Clips`, `key: green`), cropped by the frame so no feet show. For two people talking far apart, use painted panels with a paper cut instead.
## Retakes
diff --git a/skills/make-an-anime/references/tasks.md b/skills/make-an-anime/references/tasks.md
index e67ca15..0895217 100644
--- a/skills/make-an-anime/references/tasks.md
+++ b/skills/make-an-anime/references/tasks.md
@@ -159,7 +159,7 @@ Example `03_dialogue.yml` and `04_shots.yml` for a scene:
frames: 48
```
-Anime review tools (local): `review:likeness[run,...]` stacks character sheets under their numbered reference photos; `review:camera` measures each H3 shot's camera move (first vs last frame) beside its directed `camera:` and writes a ~4 fps strip per shot (`review/camera/<shot>_strip.jpg`) for spotting H3-inserted cuts by eye; `dialogue:timeline` checks talking shots and cuts against the generated lines. `scene:new[run,frames]` scaffolds a scene; `episode:preview[out.mp4,ep01]` joins the scenes' finals, each leveled to `LUFS` (default −23; `LUFS=off`).
+Anime review tools (local): `review:likeness[run,...]` stacks character sheets under their numbered reference photos; `review:believable` checks RUN against [believable-motion.md](believable-motion.md) (action on green, treadmill runs, garbling VFX values, with warnings and a by-eye list); `review:camera` measures each H3 shot's camera move (first vs last frame) beside its directed `camera:` and writes a ~4 fps strip per shot (`review/camera/<shot>_strip.jpg`) for spotting H3-inserted cuts by eye; `dialogue:timeline` checks talking shots and cuts against the generated lines. `scene:new[run,frames]` scaffolds a scene; `episode:preview[out.mp4,ep01]` joins the scenes' finals, each leveled to `LUFS` (default −23; `LUFS=off`).
`gen:dialogue` makes the lines, `review:dialogue` checks each with paid Whisper; `gen:music` with `03_score.*` composes the score; `gen:mix` (local) ducks it under the dialogue; `anim:prepare` with no argument loads the dialogue word cues for the overlay.
diff --git a/skills/make-an-anime/scripts/lib/fal_mv_gen.rb b/skills/make-an-anime/scripts/lib/fal_mv_gen.rb
index 09c0b40..7e7ffa9 100644
--- a/skills/make-an-anime/scripts/lib/fal_mv_gen.rb
+++ b/skills/make-an-anime/scripts/lib/fal_mv_gen.rb
@@ -4,6 +4,7 @@ Dir[File.join(__dir__, "media", "*.rb")].sort.each { |f| require f }
require "fal/client"
require "fal/openapi"
Dir[File.join(__dir__, "fal", "models", "*.rb")].sort.each { |f| require f }
+require "pipeline/believability"
require "pipeline/project"
require "pipeline/step"
require "pipeline/items_step"
diff --git a/skills/make-an-anime/scripts/lib/media/ffmpeg.rb b/skills/make-an-anime/scripts/lib/media/ffmpeg.rb
index fe5ed9e..058eb06 100644
--- a/skills/make-an-anime/scripts/lib/media/ffmpeg.rb
+++ b/skills/make-an-anime/scripts/lib/media/ffmpeg.rb
@@ -270,8 +270,9 @@ module Media
# Score ducked under dialogue (sidechain compression keyed by the dialogue), then limited; `seconds` long.
# music_end: hard-cut the score there (smash cut) with a 30 ms fade.
- def duck_mix(music, dialogue, out, seconds:, music_db: -4, dialogue_db: 0, duck: true, music_end: nil, music_out: 0.03)
+ def duck_mix(music, dialogue, out, seconds:, music_db: -4, dialogue_db: 0, duck: true, music_end: nil, music_out: 0.03, music_gaps: [], music_back: 1.5)
cut = music_end ? ",afade=t=out:st=#{[music_end.to_f - music_out, 0].max}:d=#{music_out}" : "" # afade out leaves silence after it
+ cut += music_gaps.map { |from, to| gap_filter(from, to, 0.03, music_back) }.join
fmt = "aresample=44100,aformat=sample_fmts=fltp:channel_layouts=stereo"
inputs = ["-i", music]
graph = if dialogue
@@ -288,6 +289,11 @@ module Media
out
end
+ # Silence between two times: gain 1 before, 0 inside, then back to 1 over `back` seconds.
+ def gap_filter(from, to, out, back)
+ ",volume='max(clip((#{from.to_f}-t)/#{out.to_f},0,1),clip((t-#{to.to_f})/#{back.to_f},0,1))':eval=frame"
+ end
+
# Lengthen a score past its last note: the final second rings out as decaying echoes under a fade, so a scene held a
# little longer lets the music release instead of stopping on the cut. Nothing before the last `release` seconds changes.
def ring_out(audio, out, tail:, release: 0.25)
diff --git a/skills/make-an-anime/scripts/lib/media/python.rb b/skills/make-an-anime/scripts/lib/media/python.rb
index a898d49..aebae86 100644
--- a/skills/make-an-anime/scripts/lib/media/python.rb
+++ b/skills/make-an-anime/scripts/lib/media/python.rb
@@ -23,6 +23,11 @@ module Media
call("camera_motion.py", first, last)
end
+ # How fast the world moves in a shot, characters aside: { "world_speed" (frame widths per second), "seconds", "pairs", "tiles" }.
+ def world_motion(video)
+ call("world_motion.py", video)
+ end
+
# Per-frame position of a feature (box `size` centred at x, y in frame `from`) by template matching.
def track_template(video, x, y, size, search = size, from = 0)
call("track_template.py", video, x.to_s, y.to_s, size.to_s, search.to_s, from.to_s)
diff --git a/skills/make-an-anime/scripts/lib/pipeline/believability.rb b/skills/make-an-anime/scripts/lib/pipeline/believability.rb
new file mode 100644
index 0000000..0d8d55d
--- /dev/null
+++ b/skills/make-an-anime/scripts/lib/pipeline/believability.rb
@@ -0,0 +1,94 @@
+module Pipeline
+ # Rules that keep footage from reading as pasted-together or AI-generated (references/believable-motion.md).
+ #
+ # Green screen cannot carry action: a keyed figure has no contact with the ground, no shared light and no shared camera,
+ # so a run or a blow looks ridiculous however well it is keyed. The same failure happens without any key, when H3
+ # animates a runner's limbs over a background that hardly moves. So action is painted with its world in one H3 take,
+ # one runner per shot, with a camera that travels.
+ #
+ # The written rules run on the prompts, and Shots and Clips refuse them before any paid call. The measured rule runs on
+ # the finished take. A word match can be wrong, as in "runs a hand through his hair": such an item states why it is
+ # fine in `believable: <reason>`, which the review prints.
+ module Believability
+ RUN_WORDS = /\b(run(s|ning)?|sprint(s|ing)?|jog(s|ging)?|dash(es|ing)?|charg(e|es|ing)|chas(e|es|ing)|rac(e|es|ing)|flee(s|ing)?|rush(es|ing)?)\b/i
+ HIT_WORDS = /\b(punch(es|ing)?|kick(s|ing)?|strik(e|es|ing)|hit(s|ting)?|lung(e|es|ing)|dodg(e|es|ing)|duck(s|ing)?|parr(y|ies|ying)|tackl(e|es|ing)|throw(s|ing)?|swing(s|ing)?|fight(s|ing)?|attack(s|ing)?|clash(es|ing)?|grappl(e|es|ing)|jump(s|ing)?|leap(s|ing)?|fl(y|ies|ying)|fall(s|ing)?)\b/i
+ GROUP_WORDS = /\b(each other|both|together|two (men|women|people|fighters|runners|characters|boys|girls)|they)\b/i
+ TRACKING_CAMERA = /\b(track(s|ing)?|truck(s|ing)?|follow(s|ing)?|travel(s|ling|ing)?|alongside|steadicam|dolly (beside|with|ahead))\b/i
+ NEGATED = /\b(no|not|never|without|nobody|nothing|don't|doesn't)\b[^.,;:]*/i
+ PASTED_EFFECTS = /Anim\.(aura|shockRing|impactBloom|speedLines|embers)\b/
+ FULL_TURN = /\b(360|full (rotation|orbit|circle|turn)|spin(s|ning)? around)\b/i
+
+ # Near-ground speed below this, in frame widths per second, is a treadmill. Set between two real H3 takes: the two-man
+ # run the user rejected as green screen measured 0.11, the tracked single runner that replaced it 0.28. Static shots
+ # measure 0.00-0.04. Two runs are a small sample, so read the strip as well.
+ MIN_RUN_WORLD_SPEED = 0.20
+ MAX_RGB_SPLIT = 0.05
+
+ module_function
+
+ # What the prompt actually asks for: the style bible and the negated phrases are removed, so a style that mentions a
+ # fight, or "no running" and "nobody falls", do not count as action.
+ def asserted(text) = text.to_s.sub(Project.style.to_s, " ").gsub(NEGATED, " ")
+
+ def camera_text(spec)
+ camera = spec["camera"]
+ camera.is_a?(Hash) ? camera.values.join(" ") : camera.to_s
+ end
+
+ def keyed?(spec) = %w[green paper].include?(spec.fetch("key", "paper"))
+
+ def generated?(spec) = !(spec["still"] || spec["color"] || spec["from_run"] || spec["same_take"] || spec["source"])
+
+ def running?(spec) = generated?(spec) && !spec["believable"] && asserted(spec["prompt"]).match?(RUN_WORDS)
+
+ # Problems in one Shots item. Each message says what to do instead.
+ def shot_problems(name, spec)
+ return [] unless running?(spec)
+ problems = []
+ unless asserted(camera_text(spec)).match?(TRACKING_CAMERA)
+ problems << "#{name}: a run with a camera that does not travel becomes a treadmill. Direct a tracking shot beside or ahead of the runner, with the world passing behind them"
+ end
+ if run_sentences(spec["prompt"]).any? { _1.match?(GROUP_WORDS) }
+ problems << "#{name}: several people run in one shot. Show one runner per shot and let the cut bring them together"
+ end
+ problems
+ end
+
+ # Problems in one Clips item.
+ def clip_problems(name, spec)
+ return [] if !keyed?(spec) || spec["believable"] || !spec["prompt"]
+ text = asserted(spec["prompt"])
+ words = [RUN_WORDS, HIT_WORDS].filter_map { text[_1] }
+ return [] if words.empty?
+ ["#{name}: action (#{words.join(", ")}) on green screen looks ridiculous. Paint the character and the world in one H3 shot instead"]
+ end
+
+ def run_sentences(prompt)
+ asserted(prompt).split(/(?<=[.!?])\s+/).select { _1.match?(RUN_WORDS) }
+ end
+
+ # Softer signals that need a look, not a refusal.
+ def warnings(shots:, clips:, overlay: nil)
+ out = []
+ keyed = clips.select { |_, spec| keyed?(spec) }.keys
+ out << "keyed sprites (#{keyed.join(", ")}): check that each stays still and that no sprite travels across the frame in p5" if keyed.any?
+ shots.each do |name, spec|
+ out << "#{name}: a full camera turn reads as a stunt. Keep the arc partial" if asserted(camera_text(spec)).match?(FULL_TURN)
+ out << "#{name}: a p5 roll on the plate needs every layer to turn with it" if spec["roll"]
+ end
+ effects = overlay.to_s.scan(PASTED_EFFECTS).flatten.uniq
+ out << "overlay draws #{effects.join(", ")}: glows and rings sit on top of the painting, so check they do not look pasted on" if effects.any?
+ out
+ end
+
+ # A colour split is a small fraction of the frame. An amt of 6 instead of 0.006 turned a knockout into four rainbow frames.
+ def cue_problems(cues)
+ Array(cues).select { |cue| cue["fx"] == "rgb" && cue["amt"].to_f > MAX_RGB_SPLIT }
+ .map { |cue| "vfx rgb at frame #{cue["f"]}: amt #{cue["amt"]} garbles the picture (typical 0.006, at most #{MAX_RGB_SPLIT})" }
+ end
+
+ def refuse!(problems)
+ raise ArgumentError, "Unbelievable footage refused before any paid call:\n #{problems.join("\n ")}\nSee references/believable-motion.md" if problems.any?
+ end
+ end
+end
diff --git a/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rb b/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rb
index 8d625d2..57e7ba6 100644
--- a/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rb
+++ b/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rb
@@ -10,7 +10,7 @@ module Pipeline
# stem from `rake media:stems`, so the mouth rests in the singer's pauses), gate: <dB> silences it below
# source: <path> an existing video in the repo
# still: <keyframe> | <run>/<keyframe> | run:<run> a keyframe of this run or another, or another run's ref_base (a single frame)
- # and the cut-out options: key: paper | green (chroma background), box: [x, y, w, h] crop in source pixels,
+ # and the cut-out options: key: paper | green (chroma background) | none (a full-frame painted take, kept opaque, e.g. a manga panel), box: [x, y, w, h] crop in source pixels,
# seed: [x, y] a point on the character (paper key: only the part connected to it is kept), frames: how many (default all),
# start: first frame, scale: resize factor, low: <0-255> a stricter green key for fire or glow cast on the green (default 25). RECUT=1 ONLY=<name> FORCE=1 re-cuts a downloaded H3 clip without a fal call.
class Clips < ItemsStep
@@ -19,6 +19,11 @@ module Pipeline
def specs = @specs ||= yaml("04_clips").to_h { |clip| [clip.fetch("name"), clip] }
+ def run!(**)
+ Believability.refuse!(specs.flat_map { |name, spec| Believability.clip_problems(name, spec) })
+ super
+ end
+
def generate(name, spec)
source, generated = source_for(name, spec)
dir = project.path("04_clips", name)
@@ -43,7 +48,10 @@ module Pipeline
end
{
board: project[key]["path"], coverage_pct: coverage,
- **verdict(coverage.to_h { |name, pct| ["#{name} cut out", [pct.between?(3, 90), "#{pct}% opaque, #{items[name]["frames"]} frames"]] })
+ **verdict(coverage.to_h do |name, pct|
+ next ["#{name} opaque", [pct >= 99, "#{pct}% opaque, #{items[name]["frames"]} frames"]] if specs.dig(name, "key") == "none"
+ ["#{name} cut out", [pct.between?(3, 90), "#{pct}% opaque, #{items[name]["frames"]} frames"]]
+ end)
}
end
diff --git a/skills/make-an-anime/scripts/lib/pipeline/steps/dialogue.rb b/skills/make-an-anime/scripts/lib/pipeline/steps/dialogue.rb
index 985eb06..c23cafd 100644
--- a/skills/make-an-anime/scripts/lib/pipeline/steps/dialogue.rb
+++ b/skills/make-an-anime/scripts/lib/pipeline/steps/dialogue.rb
@@ -95,7 +95,9 @@ module Pipeline
whisper = Fal::Models::Whisper.new(client: client)
heard = lines.to_h do |l|
url = data.dig("items", l["name"], "url")
- text = url ? whisper.transcribe(audio_url: url).output["text"].to_s.strip : ""
+ # Whisper defaults to English and then translates another language instead of transcribing it.
+ language = specs.dig(l["name"], "language_code") || "en"
+ text = url ? whisper.transcribe(audio_url: url, language: language).output["text"].to_s.strip : ""
[l["name"], text]
end
checks = lines.to_h do |l|
@@ -103,7 +105,7 @@ module Pipeline
got = self.class.spoken(heard[l["name"]])
missing, extra = self.class.word_diff(want, got)
["#{l["name"]} (#{l["character"]}) says its text", [missing.size <= [1, want.size / 6].max && extra.size <= [1, want.size / 6].max,
- "heard #{heard[l["name"]].inspect}; missing #{missing.inspect}; extra #{extra.inspect}"]]
+ "heard #{heard[l["name"]].inspect}; missing #{missing.inspect}; extra #{extra.inspect}#{"; not Latin script, so compare it by reading" if want.empty?}"]]
end
tracks = data["tracks"].transform_values { |p| ffmpeg.summary(p)[:duration] }
checks["mouth tracks are scene length"] = [tracks.values.all? { |d| (d - project.duration).abs < 0.05 }, tracks.inspect]
diff --git a/skills/make-an-anime/scripts/lib/pipeline/steps/mix.rb b/skills/make-an-anime/scripts/lib/pipeline/steps/mix.rb
index 072d7a7..fc7cb19 100644
--- a/skills/make-an-anime/scripts/lib/pipeline/steps/mix.rb
+++ b/skills/make-an-anime/scripts/lib/pipeline/steps/mix.rb
@@ -3,7 +3,8 @@ module Pipeline
# Step 3c — the scene soundtrack (local, no Fal call): the score (Music step) ducked under the dialogue (Dialogue step),
# limited, at the scene's exact length -> 03_mix.wav. Shots, Overlay and the final assembly use it via Project#soundtrack.
# Generation option `mix: { music_db: -4, dialogue_db: 0, duck: true, music_end: 19.5 }`; music_end hard-cuts the score
- # (a smash cut) with a 30 ms fade, or over music_out seconds; ambience and spot effects are added later by sfx:mix.
+ # (a smash cut) with a 30 ms fade, or over music_out seconds; music_gaps: [[20.0, 48.0]] silences the score between those
+ # seconds (cut out in 30 ms, back in over music_back seconds, default 1.5) for a scene held on silence; ambience and spot effects are added later by sfx:mix.
# voice_lift_db raises the voice over the bed and writes 03_mix_ref.wav without it (see Media::Sfx#voice_args).
# A mix older than its score or dialogue file is stale and is rebuilt without FORCE (a music retake used to leave the
# old mix in 03_mix.wav and final.mp4).
diff --git a/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rb b/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rb
index a2aa533..320e261 100644
--- a/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rb
+++ b/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rb
@@ -15,6 +15,8 @@ module Pipeline
# still: <keyframe> no generation: the keyframe held (zoom: [1.0, 1.06] for a slow push) — inserts, held drawings
# color: "#05070a" no generation: a solid frame the overlay draws on (screens, title cards, smash-cut white)
# from_run: <run> no generation: that run's video (same timeline) from this shot's position
+ # same_take: <shot> no generation: the footage of an earlier shot of this list, from skip_frames on, for a beat that must
+ # repeat exactly (a running gag). Place the repeated line at the same offset inside the shot.
# The shots are cut, concatenated and muxed with the scene soundtrack (Mix, else Music) -> final.mp4 (the Overlay plate).
class Shots < ItemsStep
MODEL = Fal::Models::H3MaxImageToVideo
@@ -38,6 +40,11 @@ module Pipeline
# changes (frames, colour, still, zoom) — no FORCE needed. A white card once kept its old 12 frames after its
# frames were raised to 96 because a cached local shot counted as done. Items from before this record no spec:
# those are compared by frame count only.
+ def run!(**)
+ Believability.refuse!(specs.flat_map { |name, spec| Believability.shot_problems(name, spec) })
+ super
+ end
+
def stale_item?(name, spec, item)
return false unless spec["still"] || spec["color"]
stale = item["spec"] ? item["spec"] != local_spec(spec) : ffmpeg.summary(item["path"]).dig(:video, :frames).to_i != spec["frames"]
@@ -51,6 +58,10 @@ module Pipeline
if (run = spec["from_run"])
return { source: run, path: Project.new(run).fetch!(:video, :path) }
end
+ if (take = spec["same_take"])
+ raise ArgumentError, "shot #{name}: same_take #{take} is not an earlier generated shot" unless reusable_take?(name, take)
+ return { source: take, path: project.path("04_shot_#{take}.mp4") }
+ end
if spec["still"] || spec["color"]
image = spec["still"] && keyframe_path(spec["still"])
out = ffmpeg.still_video(project.path("04_shot_#{name}.mp4"), frames: spec["frames"], fps: FPS, image: image,
@@ -82,7 +93,7 @@ module Pipeline
def finish(items)
segments = specs.map do |name, spec|
{ path: items[name]["path"], frames: spec["frames"], retime: spec["retime"], keep: spec["source_frames"],
- skip: spec["from_run"] ? spec["start_frame"] : 0, roll: spec["roll"] }
+ skip: source_skip(spec), roll: spec["roll"] }
end
plate = ffmpeg.concat_shots(segments, project.path("04_plate.mp4"), fps: FPS, w: 1920, h: 1080) # 768P H3 shots upscaled to the 1080p delivery
{ path: ffmpeg.mux(plate, project.soundtrack, project.path("final.mp4"), shortest: false), plate: plate }
@@ -98,9 +109,9 @@ module Pipeline
[ffmpeg.frame_index(final, n, project.review_path(key, "f#{n}.jpg")), "f#{n} #{label}"]
end
end
- # Frames each source must have: from_run sources are read from the shot's position, generated ones from 0.
+ # Frames each source must have: from_run and same_take sources start part way in, generated ones at 0.
short = specs.reject do |name, s|
- s["retime"] || s["still"] || s["color"] || ffmpeg.summary(project[key]["items"][name]["path"]).dig(:video, :frames).to_i >= (s["from_run"] ? s["start_frame"] : 0) + s["frames"]
+ s["retime"] || s["still"] || s["color"] || ffmpeg.summary(project[key]["items"][name]["path"]).dig(:video, :frames).to_i >= source_skip(s) + s["frames"]
end
{
summary: summary, contact_sheet: ffmpeg.contact_sheet(final, project.review_path(key, "contact_sheet.jpg"), cols: 6, rows: 3),
@@ -120,6 +131,18 @@ module Pipeline
private
+ def source_skip(spec)
+ return spec["start_frame"] if spec["from_run"]
+
+ spec.fetch("skip_frames", 0)
+ end
+
+ def reusable_take?(name, take)
+ names = specs.keys
+ source = specs[take]
+ source && names.index(take) < names.index(name) && !source["still"] && !source["color"] && !source["from_run"] && !source["same_take"]
+ end
+
# The shot's own length (H3 may add ~0.7 s), at least 2 s when audio is pinned, rounded up to 0.1 s.
def default_seconds(spec)
[(spec["frames"].fdiv(FPS) * 10).ceil / 10.0, spec["audio"] ? 2.0 : 1.0].max
diff --git a/skills/make-an-anime/scripts/lib/toolkit/anime_review.rb b/skills/make-an-anime/scripts/lib/toolkit/anime_review.rb
index 1742cff..962c3b4 100644
--- a/skills/make-an-anime/scripts/lib/toolkit/anime_review.rb
+++ b/skills/make-an-anime/scripts/lib/toolkit/anime_review.rb
@@ -9,6 +9,9 @@ module Toolkit
# (e.g. v2,v3) are stacked so alternatives compare against the same photos.
# review:camera per H3 shot of RUN: a frame strip, the measured camera move (zoom / pan / tilt between
# the first and last frame) next to the directed `camera:` move, and a verdict hint.
+ # review:believable RUN's prompts and finished takes against references/believable-motion.md: action on green,
+ # a run with a static camera or several runners, and a measured treadmill (a run whose world
+ # hardly moves), plus softer warnings and the by-eye checklist. Works before generating too.
# dialogue:timeline RUN's shots and lines on one timeline with the checks that matter before animating:
# every `audio:` shot contains its speaker's whole on-screen line, no on-screen line
# crosses a cut, the shortest frame count each talking shot needs.
@@ -16,6 +19,7 @@ module Toolkit
FPS = 24
# A camera estimate below this match score is unreliable: strong parallax, a big character move or a morph.
TRUST = 0.65
+ BELIEVABLE_CHECK = "Watch at normal speed: feet land where the body travels, light on the characters matches their background, nothing outlined or floating, nobody runs in place, each blow connects, and no glow or ring looks pasted on."
def initialize(project = Pipeline::Project.new)
@project = project
@@ -65,6 +69,29 @@ module Toolkit
end
end
+ def believable
+ shots = prompt_file("04_shots") ? Pipeline::Steps::Shots.new(project: project).specs : {}
+ clips = prompt_file("04_clips") ? Pipeline::Steps::Clips.new(project: project).specs : {}
+ issues = shots.flat_map { |name, spec| Pipeline::Believability.shot_problems(name, spec) } +
+ clips.flat_map { |name, spec| Pipeline::Believability.clip_problems(name, spec) }
+ runs = shots.select { |_, spec| Pipeline::Believability.running?(spec) }.filter_map do |name, spec|
+ video = project.path("04_shot_#{name}.mp4")
+ next { shot: name, measured: "not generated yet" } unless File.file?(video)
+ measured = python.world_motion(video)
+ speed = measured["world_speed"] * retime_factor(spec, measured["seconds"])
+ min = Pipeline::Believability::MIN_RUN_WORLD_SPEED
+ issues << format("%s: treadmill, the world moves %.2f frame widths per second behind a run (at least %.2f). Retake with more camera travel", name, speed, min) if speed < min
+ { shot: name, world_speed: speed.round(3), minimum: min }
+ end
+ cues = File.join(Pipeline::ROOT, "prompts", "#{project.name}-vfx", "cues.yml")
+ issues.concat(Pipeline::Believability.cue_problems(YAML.safe_load_file(cues)["cues"])) if File.file?(cues)
+ overlay = prompt_file("05_overlay")
+ { run: project.name, ok: issues.empty?, issues: issues, measured_runs: runs,
+ warnings: Pipeline::Believability.warnings(shots: shots, clips: clips, overlay: overlay && File.read(overlay)),
+ accepted_by_author: (shots.merge(clips)).select { |_, spec| spec["believable"] }.transform_values { _1["believable"] },
+ check_by_eye: BELIEVABLE_CHECK }
+ end
+
def timeline
lines_path = project.path("03_dialogue_lines.json")
raise ArgumentError, "run gen:dialogue first (#{lines_path})" unless File.file?(lines_path)
@@ -98,6 +125,15 @@ module Toolkit
private
+ # How much faster a retimed take plays in the edit than the file on disk.
+ def retime_factor(spec, seconds)
+ return 1.0 unless spec["retime"]
+ source = spec["source_frames"] || (seconds * FPS)
+ source.to_f / spec["frames"]
+ end
+
+ def prompt_file(stem) = Dir[File.join(Pipeline::ROOT, "prompts", project.name, "#{stem}.*")].first
+
def reference_photos(p)
Array(p.generation[:photos]).map { |f| File.expand_path(f, Pipeline::ROOT) }
.reject { |f| f.include?("/output/") } # sheets passed as style references
diff --git a/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb b/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb
index ede5ed2..260d3e6 100644
--- a/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb
+++ b/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb
@@ -11,7 +11,7 @@ module Toolkit
class CredentialTasks
TASKS = %w[doctor audio:transcribe media:stems media:upload sfx:gen
pipeline:all adopt gen:ref_base gen:ref_torn gen:keyframes gen:video
- gen:shots gen:clips gen:music gen:dialogue gen:mix gen:overlay review:music review:dialogue review:likeness review:camera dialogue:timeline scene:new episode:preview].freeze
+ gen:shots gen:clips gen:music gen:dialogue gen:mix gen:overlay review:music review:dialogue review:likeness review:camera review:believable dialogue:timeline scene:new episode:preview].freeze
OPTIONS = %w[RUN ONLY FORCE RECUT NEW_REQUEST VIDEO_RES SFX VFX REFRESH_UPLOAD].freeze
OUTPUT_LIMIT = 20_000
MAX_RUNNING = 10
diff --git a/skills/make-an-anime/scripts/lib/toolkit/operations.rb b/skills/make-an-anime/scripts/lib/toolkit/operations.rb
index f3d64cf..244ff00 100644
--- a/skills/make-an-anime/scripts/lib/toolkit/operations.rb
+++ b/skills/make-an-anime/scripts/lib/toolkit/operations.rb
@@ -23,6 +23,7 @@ module Toolkit
"pipeline:status" => "Show RUN's generated/reviewed steps",
"review:likeness" => "Character sheet(s) beside their reference photos: [run,run2,...] (local)",
"review:camera" => "Measured vs directed camera move for RUN's H3 shots, with frame strips (local)",
+ "review:believable" => "RUN's prompts and takes against the believable-motion rules: action on green, treadmill runs (local)",
"scene:new" => "Scaffold an anime scene: [run,frames] -> prompts/<run>/, prompts/<run>-sfx/, config/generations/<run>.rb (local)",
"scene:reaudio" => "Put RUN's current mix on its rendered overlay: [run] (picture copied, local)",
"scene:vfx" => "Film-frame cues from scene-frame beats: [vfx_name], prompts/<name>/beats.yml -> cues.yml (local)",
@@ -89,6 +90,7 @@ module Toolkit
when "openapi:summary" then endpoints.each { |id| puts Fal::OpenAPI.load(id).summary if File.file?(Fal::OpenAPI.spec_path(id)) }
when "review:likeness" then emit AnimeReview.new.likeness(a)
when "review:camera" then emit AnimeReview.new.camera
+ when "review:believable" then emit AnimeReview.new.believable
when "dialogue:timeline" then emit AnimeReview.new.timeline
when "scene:new" then required(a, 2); emit Episode.new.scaffold(a[0], a[1])
when "audio:seams" then required(a, 1); emit Episode.new.seam_report(a[0], a[1] || "ep01")
diff --git a/skills/make-an-anime/scripts/spec/anime_spec.rb b/skills/make-an-anime/scripts/spec/anime_spec.rb
index a28d2b1..d6f379b 100644
--- a/skills/make-an-anime/scripts/spec/anime_spec.rb
+++ b/skills/make-an-anime/scripts/spec/anime_spec.rb
@@ -167,3 +167,117 @@ RSpec.describe "Anime scene pipeline", :media do
end
end
+
+RSpec.describe "Reused takes and Whisper language", :core do
+ it "reuses the footage of an earlier generated shot and refuses anything else" do
+ specs = { "bite" => { "image" => "a", "frames" => 96 }, "held" => { "still" => "a", "frames" => 24 },
+ "again" => { "same_take" => "bite", "skip_frames" => 29, "frames" => 60 },
+ "bad_still" => { "same_take" => "held", "frames" => 12 }, "bad_order" => { "same_take" => "later", "frames" => 12 },
+ "later" => { "image" => "a", "frames" => 24 } }
+ shots = Pipeline::Steps::Shots.allocate
+ allow(shots).to receive(:specs).and_return(specs)
+ allow(shots).to receive(:project).and_return(double(path: "/out/04_shot_bite.mp4"))
+ expect(shots.send(:generate, "again", specs["again"])).to eq(source: "bite", path: "/out/04_shot_bite.mp4")
+ expect(shots.send(:source_skip, specs["again"])).to eq(29)
+ expect { shots.send(:generate, "bad_still", specs["bad_still"]) }.to raise_error(ArgumentError, /not an earlier generated shot/)
+ expect { shots.send(:generate, "bad_order", specs["bad_order"]) }.to raise_error(ArgumentError, /not an earlier generated shot/)
+ expect(Pipeline::Believability.generated?(specs["again"])).to be(false)
+ end
+
+ it "asks Whisper for the language of each line, so Japanese is transcribed and not translated" do
+ with_workspace do |dir|
+ lines = File.join(dir, "lines.json")
+ File.write(lines, JSON.generate([{ "name" => "ja", "character" => "a", "text" => "はい" }, { "name" => "en", "character" => "a", "text" => "yes" }]))
+ data = { "lines" => lines, "tracks" => {}, "items" => { "ja" => { "url" => "u1" }, "en" => { "url" => "u2" } } }
+ step = Pipeline::Steps::Dialogue.allocate
+ allow(step).to receive_messages(key: :dialogue, client: nil, project: { dialogue: data }.tap { |h| h.define_singleton_method(:duration) { 1.0 } },
+ specs: { "ja" => { "language_code" => "ja" }, "en" => {} })
+ whisper = double
+ allow(Fal::Models::Whisper).to receive(:new).and_return(whisper)
+ allow(whisper).to receive(:transcribe).and_return(double(output: { "text" => "" }))
+ step.send(:review)
+ expect(whisper).to have_received(:transcribe).with(audio_url: "u1", language: "ja")
+ expect(whisper).to have_received(:transcribe).with(audio_url: "u2", language: "en")
+ end
+ end
+end
+
+RSpec.describe "Believable motion rules", :core do
+ rules = Pipeline::Believability
+
+ def run_spec(prompt, camera) = { "prompt" => prompt, "camera" => { "move" => camera } }
+
+ it "refuses action on green and accepts a performance that stays put" do
+ fight = { "key" => "green", "prompt" => "He sprints forward and throws a punch." }
+ talk = { "key" => "green", "prompt" => "He stands still and says his line. Nobody runs. No fighting." }
+ expect(rules.clip_problems("a", fight).first).to include("sprints", "throws", "one H3 shot")
+ expect(rules.clip_problems("b", talk)).to eq([])
+ end
+
+ it "does not treat a full-frame painted clip as a keyed one" do
+ expect(rules.clip_problems("panel", { "key" => "none", "prompt" => "He punches the air." })).to eq([])
+ end
+
+ it "ignores action words that only appear in the style bible" do
+ allow(Pipeline::Project).to receive(:style).and_return("A story about a fight.")
+ expect(rules.clip_problems("a", { "key" => "green", "prompt" => "A story about a fight. He stands and talks." })).to eq([])
+ end
+
+ it "refuses a run without a travelling camera, and several runners in one shot" do
+ locked = run_spec("He sprints along the river.", "locked-off")
+ pair = run_spec("They sprint towards each other.", "fast lateral tracking shot")
+ tracked = run_spec("He sprints along the river. The world rushes past.", "fast lateral tracking shot")
+ expect(rules.shot_problems("locked", locked).join).to include("treadmill")
+ expect(rules.shot_problems("pair", pair).join).to include("one runner per shot")
+ expect(rules.shot_problems("tracked", tracked)).to eq([])
+ end
+
+ it "accepts a flagged word when the item explains itself" do
+ hair = run_spec("He runs a hand through his hair.", "locked-off").merge("believable" => "no running, only a hand gesture")
+ expect(rules.shot_problems("hair", hair)).to eq([])
+ end
+
+ it "stops a paid shot step before the first call" do
+ step = Pipeline::Steps::Shots.allocate
+ allow(step).to receive(:specs).and_return("bad" => run_spec("They sprint at each other.", "push-in"))
+ expect { step.run! }.to raise_error(ArgumentError, /refused before any paid call/)
+ end
+
+ it "stops a paid clip step before the first call" do
+ step = Pipeline::Steps::Clips.allocate
+ allow(step).to receive(:specs).and_return("bad" => { "key" => "green", "prompt" => "He sprints." })
+ expect { step.run! }.to raise_error(ArgumentError, /refused before any paid call/)
+ end
+
+ it "catches a colour split large enough to garble the picture" do
+ expect(rules.cue_problems([{ "fx" => "rgb", "f" => 242, "amt" => 6 }]).join).to include("garbles")
+ expect(rules.cue_problems([{ "fx" => "rgb", "f" => 242, "amt" => 0.006 }, { "fx" => "grain", "amt" => 3 }])).to eq([])
+ end
+
+ it "warns about pasted-on effects, sprites and full turns" do
+ notes = rules.warnings(shots: { "s" => { "camera" => "a 360 orbit" } }, clips: { "c" => { "key" => "green" } }, overlay: "Anim.shockRing(x, y, p);")
+ expect(notes.join).to include("keyed sprites (c)", "full camera turn", "shockRing")
+ end
+end
+
+RSpec.describe "Near-ground motion measure", :media do
+ # A textured ground under a fixed sky, with a block standing in for a runner whose limbs move while the ground stays.
+ def clip(path, ground_speed)
+ Open3.capture2e("ffmpeg", "-y", "-v", "error", "-f", "lavfi", "-i", "nullsrc=s=960x540:r=24:d=2",
+ "-vf", "geq=lum='128+60*sin((X+#{ground_speed}*N)/9)*sin(Y/7)':cb=128:cr=128,format=yuv420p", path).last.success? or raise "ffmpeg failed"
+ path
+ end
+
+ def world_speed(path)
+ out, status = Open3.capture2(Media::Python.new.executable, File.join(SKILL, "scripts", "tools", "python", "world_motion.py"), path)
+ raise out unless status.success?
+ JSON.parse(out)["world_speed"]
+ end
+
+ it "reads a still ground as a treadmill and a passing ground as travel" do
+ Dir.mktmpdir do |dir|
+ expect(world_speed(clip(File.join(dir, "still.mp4"), 0))).to be < 0.05
+ expect(world_speed(clip(File.join(dir, "moving.mp4"), 16))).to be > Pipeline::Believability::MIN_RUN_WORLD_SPEED
+ end
+ end
+end
diff --git a/skills/make-an-anime/scripts/spec/episode_spec.rb b/skills/make-an-anime/scripts/spec/episode_spec.rb
index 023fbe1..c0cc599 100644
--- a/skills/make-an-anime/scripts/spec/episode_spec.rb
+++ b/skills/make-an-anime/scripts/spec/episode_spec.rb
@@ -138,4 +138,15 @@ RSpec.describe "Episode preview", :media do
lifted = ff.duck_mix(music, voice, file("lift.wav"), seconds: 3, duck: false, music_db: -60, dialogue_db: 6)
expect(ff.loudness(lifted)[:lufs]).to be > ff.loudness(plain)[:lufs] + 3
end
+
+ it "silences the score in a music gap with a hard cut, whatever music_out the end of the film uses" do
+ music = tone(file("gap_music.wav"), duration: 4)
+ out = ff.duck_mix(music, nil, file("gap.wav"), seconds: 4, music_db: 0, music_end: 4, music_out: 1.0, music_gaps: [[1.0, 2.0]], music_back: 0.1)
+ level = py.audio_energy(out)["windows"]
+ at = ->(from, to) { level.select { |w| w["t"] >= from && w["t"] < to }.map { _1["rms_db"] } }
+ before, inside, after = at.(0.2, 0.7), at.(1.2, 1.8), at.(2.3, 2.8)
+ expect(inside.max).to be < -60
+ expect(before.min).to be > -40 # not already fading towards the gap
+ expect(after.min).to be_within(1).of(before.min) # and back at full level after it
+ end
end
diff --git a/skills/make-an-anime/scripts/tools/p5/lib/screens.js b/skills/make-an-anime/scripts/tools/p5/lib/screens.js
index 9549d28..c81fe64 100644
--- a/skills/make-an-anime/scripts/tools/p5/lib/screens.js
+++ b/skills/make-an-anime/scripts/tools/p5/lib/screens.js
@@ -142,7 +142,7 @@ window.Anim = window.Anim || {};
Anim.spoken = (lines) => lines.map((l) => (l.speech_at != null ? { ...l, at: Math.max(l.at, l.speech_at) } : l));
const spokenCache = new WeakMap();
- Anim.subtitles = (t, lines, { font, italic = font, size = 46, y = height - 92, lead = 0.05, tail = 0.35, skip = () => false } = {}) => {
+ Anim.subtitles = (t, lines, { font, italic = font, size = 46, x = width / 2, y = height - 92, lead = 0.05, tail = 0.35, skip = () => false } = {}) => {
if (!spokenCache.has(lines)) spokenCache.set(lines, Anim.spoken(lines));
const l = spokenCache.get(lines).find((x) => t >= x.at - lead && t < x.end + tail && !skip(x));
if (!l) return null;
@@ -150,12 +150,45 @@ window.Anim = window.Anim || {};
const a = Anim.envelope(t, l.at - lead, l.end + tail, 0.12, 0.2);
textFont(l.vo ? italic : font); textSize(size); textAlign(CENTER, BASELINE);
drawingContext.shadowBlur = 14; drawingContext.shadowColor = `rgba(0,0,0,${0.9 * a})`;
- fill(0, 0, 0, 150 * a); text(str, width / 2 + 2, y + 2);
- fill(255, 255, 255, 255 * a); text(str, width / 2, y);
+ fill(0, 0, 0, 150 * a); text(str, x + 2, y + 2);
+ fill(255, 255, 255, 255 * a); text(str, x, y);
drawingContext.shadowBlur = 0;
return l;
};
+ // A manga page: two painted panels with a paper cut between them, so two people who are far apart can talk on one screen.
+ // drawLeft and drawRight each paint a full frame and are clipped to their side. cut: [x at the top, x at the bottom].
+ // The cut is a strip of off-white paper with a slightly uneven scissor edge, a thin ink line and a soft cast shadow.
+ // Paint each panel as one H3 take with its own world, not a keyed sprite (references/believable-motion.md).
+ Anim.paperCutPanels = (drawLeft, drawRight, { cut = [width * 0.54, width * 0.46], gutter = 22, paper = "#f4efe3", ink = "rgba(18,16,14,0.92)", seed = 7 } = {}) => {
+ const g = drawingContext;
+ const jitter = (i, side) => {
+ const v = Math.sin((i + 1) * 12.9898 + seed * 78.233 + side * 37.719) * 43758.5453;
+ return (v - Math.floor(v) - 0.5) * 4;
+ };
+ const STEP = 30, rows = Math.ceil(height / STEP);
+ const edge = (side) => Array.from({ length: rows + 1 }, (_, i) => {
+ const y = Math.min(height, i * STEP);
+ return [cut[0] + (cut[1] - cut[0]) * (y / height) + (side * gutter) / 2 + jitter(i, side), y];
+ });
+ const trace = (points, closeAt) => {
+ g.beginPath();
+ points.forEach(([x, y], i) => (i ? g.lineTo(x, y) : g.moveTo(x, y)));
+ if (closeAt != null) { g.lineTo(closeAt, height); g.lineTo(closeAt, 0); g.closePath(); }
+ };
+ const left = edge(-1), right = edge(1);
+ g.save(); g.fillStyle = paper; g.fillRect(0, 0, width, height); g.restore();
+ g.save(); trace(left, 0); g.clip(); drawLeft(); g.restore();
+ g.save(); trace(right, width); g.clip(); drawRight(); g.restore();
+ for (const points of [left, right]) {
+ g.save();
+ g.shadowColor = "rgba(0,0,0,0.55)"; g.shadowBlur = 14;
+ g.strokeStyle = ink; g.lineWidth = 3; g.lineJoin = "round";
+ trace(points); g.stroke();
+ g.restore();
+ }
+ };
+
// Place/date card ("CITY · 1999"): letter-spaced, fading in.
Anim.placeCard = (local, str, { font, size = 64, color = [40, 44, 52], alpha = 0.75, at = 0.05, fade = 0.3, spacing = 18, y = height / 2 } = {}) => {
const a = Anim.tween(local, at, fade, 0, alpha);
diff --git a/skills/make-an-anime/scripts/tools/python/world_motion.py b/skills/make-an-anime/scripts/tools/python/world_motion.py
new file mode 100644
index 0000000..cb9275d
--- /dev/null
+++ b/skills/make-an-anime/scripts/tools/python/world_motion.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python3
+"""How fast the near ground passes in a shot, ignoring the characters (numpy + ffmpeg only).
+
+usage: world_motion.py VIDEO
+
+A running character needs the world to pass behind them. A figure pumping its limbs over a ground that hardly moves
+reads as a green-screen treadmill, whether or not it was keyed. Only the near ground tells them apart: in a real tracking
+shot the sky, the sun and a far bridge barely move, so a measure over the whole frame scores a good run below a bad one.
+
+The lower part of each sampled pair of frames is split into tiles, and each tile gets its own horizontal and vertical
+shift by phase correlation. The median tile is the ground, because a runner's legs cover a minority of the tiles.
+
+Prints JSON:
+ {"world_speed": 0.62, "seconds": 3.04, "pairs": 36, "tiles": 8.0}
+world_speed: median speed of the near ground, in frame widths per second.
+tiles: average number of textured tiles used per pair (few tiles mean a flat picture and a weak estimate).
+"""
+import json
+import subprocess
+import sys
+
+import numpy as np
+
+W, H = 480, 270
+BAND_TOP = 0.55 # the near ground: the bottom 45% of the frame
+COLS, ROWS = 4, 2 # wide tiles, because fast ground can move far between two frames
+STEP = 2 # frames between the two frames of a pair
+MIN_TEXTURE = 3.0 # grey-level standard deviation below which a tile is too flat to give a shift
+
+
+def fps_of(path):
+ out = subprocess.run(
+ ["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=r_frame_rate",
+ "-of", "csv=p=0", path], capture_output=True, check=True, text=True).stdout.strip().split(",")[0]
+ num, den = out.split("/")
+ return float(num) / float(den)
+
+
+def frames(path):
+ proc = subprocess.Popen(
+ ["ffmpeg", "-v", "error", "-i", path, "-vf", f"scale={W}:{H}", "-f", "rawvideo", "-pix_fmt", "gray", "-"],
+ stdout=subprocess.PIPE)
+ size = W * H
+ while (buf := proc.stdout.read(size)) and len(buf) == size:
+ yield np.frombuffer(buf, dtype=np.uint8).reshape(H, W).astype(np.float64)
+ proc.wait()
+
+
+def tile_shift(a, b):
+ """Pixels between two tiles by phase correlation."""
+ h, w = a.shape
+ win = np.outer(np.hanning(h), np.hanning(w))
+ fa, fb = np.fft.fft2((a - a.mean()) * win), np.fft.fft2((b - b.mean()) * win)
+ r = fb * np.conj(fa)
+ r /= np.abs(r) + 1e-9
+ corr = np.fft.ifft2(r).real
+ dy, dx = np.unravel_index(np.argmax(corr), corr.shape)
+ dy = dy - h if dy > h // 2 else dy
+ dx = dx - w if dx > w // 2 else dx
+ return float(np.hypot(dy, dx))
+
+
+def pair_motion(a, b):
+ """Median shift of the textured ground tiles, in pixels, and how many tiles were usable."""
+ top = int(H * BAND_TOP)
+ th, tw = (H - top) // ROWS, W // COLS
+ shifts = []
+ for row in range(ROWS):
+ for col in range(COLS):
+ y, x = top + row * th, col * tw
+ ta = a[y:y + th, x:x + tw]
+ if ta.std() >= MIN_TEXTURE:
+ shifts.append(tile_shift(ta, b[y:y + th, x:x + tw]))
+ return (float(np.median(shifts)), len(shifts)) if shifts else (0.0, 0)
+
+
+def measure(path):
+ fps = fps_of(path)
+ clip = list(frames(path))
+ if len(clip) <= STEP:
+ raise SystemExit(f"{path}: too short to measure ({len(clip)} frames)")
+ pairs = [pair_motion(clip[i], clip[i + STEP]) for i in range(0, len(clip) - STEP, STEP)]
+ per_pair = float(np.median([p[0] for p in pairs]))
+ return {
+ "world_speed": round(per_pair / W / (STEP / fps), 4),
+ "seconds": round(len(clip) / fps, 3),
+ "pairs": len(pairs),
+ "tiles": round(float(np.mean([p[1] for p in pairs])), 1),
+ }
+
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ raise SystemExit("usage: world_motion.py VIDEO")
+ print(json.dumps(measure(sys.argv[1])))