Split-frame anime video
You are the editor; the user is the director. Every step ends with something to look at and a
question, and nothing that costs money runs before the user says yes. Keep batches small (1 test,
then the rest). Scripts live in scripts/ next to this file; run them with a Python that has
numpy pillow (plus torch speechbrain for step 4, mlx-whisper for steps 3 and 7).
Keys come from the environment or a .env file (GEMINI_API_KEY, OPENROUTER_API_KEY). Never
print them, never write them into project files, never commit .env.
Step 0 - Brief (ask, don't assume)
Ask in one go: what the recording is, who the presenter is (the anime one) and who stays real, the target platform and length, the message or call to action, and any claims that must not be made. Look for a brand or claim guide in the project and read it before writing any copy.
Step 1 - Frames and layout (free)
python scripts/keyframes.py --video INPUT.mp4 --out keys_src --every 10 --sheet keys_sheet.png
Show the sheet, then ask which layout:
- A. Split one recording: the default; presenter on one half.
- B. Two recordings side by side:
python scripts/compose_two.py --a guest.mp4 --b presenter.mp4 --layout side --out clean.mp4. - C. Two recordings top and bottom:
--layout stack. Head steps work on either half; the moving seam is left/right only. Then have the user sort the numbered frames: A hands down or in the air (safe: head only), B hand on face (redraws a hand: risky, offer to skip), C show the whole real frame (phone held to camera, presenter out of shot), X exclude (two hands near the face, heavy motion).
Step 2 - Transcript and cleanup (free, local)
Transcribe with Whisper (mlx-whisper, large-v3-turbo, word timestamps) into words.json
([[start, end, "word"], ...]). Read it and propose, with timestamps: rambling or repeated parts
to cut, where the punchline is, and lines worth keeping verbatim. Cut on silences
(ffmpeg silencedetect -24dB d=0.15) into clean.mp4. Show the cut list; the user decides.
Step 3 - Script (free)
Rewrite the presenter's lines as a short monologue (script.json: [{"id":1,"text":"...","src":0.0}],
src = where in clean.mp4 the footage for that line starts). Keep the user's punchlines, keep
claims inside their guide, and propose captions (sparse highlight cards, not a full transcript).
Default structure: presenter intro (anime voice) -> guest only (real audio, overlaps cut) ->
presenter closing line + end cards. No switching voices mid-sentence.
Step 4 - Who speaks when (free, local)
python scripts/speakers.py --media clean.mp4 --presenter 0-40 --guest 300-330 --out labels.json
(time ranges where only that person speaks). ECAPA speaker embeddings; pitch tracking and
resemblyzer were not reliable enough. Overlaps and unclear windows are labelled O and cut.
It takes about 2 minutes of laptop CPU per minute of audio: start it in the background early.
Step 5 - Avatar (about $0.04 per option)
Ask what they want (close to their real face? a funny hairstyle? a beard, no moustache?).
python scripts/make_avatar.py --frame keys_src/008.png --ideas "simple clean anime, close to my face" "huge funny pompadour, pointy goatee"
Show the options; iterate on the favourite. The winner becomes the single reference for every
frame: mixed faces were the first thing the user rejected.
Step 6 - Heads (about $0.04 per frame; ~15 frames)
Write jobs.json with an expression per A-frame (vary them: grin, smirk, wink, shock, calm smile)
and a pose sentence for turned or tilted heads. Run ONE first:
python scripts/gen_heads.py --src keys_src --ref avatars/option_2.png --out heads --jobs jobs.json --character "<describe the avatar>"
Then the rest, then python scripts/head_tools.py sheet --heads heads --out heads_sheet.png and
ask the user to point at problems. Fixes that work:
- Extra or floating hands, impossible arms - already handled: only the head is kept, everything
from the neck down is the real photo (
head_tools.py composite). Prompting harder does not fix it, and a head-only reference made the model lose head size and position. - Unchanged photo returned - the script rejects it (change <= 35) and retries.
- A hand drawn beside the head - re-run
compositewith--mask-left N. - Real scalp peeking out - fill it from a median background plate of all keyframes.
- Side profiles that come back as the back of a head: keep a front-facing frame instead; the pose only shows for a few seconds.
Step 7 - Mouths and voice (about $0.04 per sprite; ~$0.1-0.4 voice)
For each talking pose: python scripts/head_tools.py mouth --base heads/C2.png --out heads/C2_open.png --state open
(--state close for faces that are already open, saved as C3_closed.png). Only a filled mouth
ellipse is pasted back, so eyes and hair never change. Show head_tools.py sheet --pairs as a GIF.
Voice: python scripts/tts_verified.py --script script.json --out voice --voice ash (OpenRouter
openai/gpt-audio). It verifies each line with Whisper because the model ad-libs. Play a sample and
let the user choose the voice and energy before generating all lines.
Step 8 - Plan, storyboard, render (free)
python scripts/plan_timeline.py --source clean.mp4 --labels labels.json --script script.json --voice voice --intro 1,2,3 --outro 9 --words words.json --heads heads --out plan.json
Print the storyboard; go through it with the user and delete clip entries that ramble. Set
poses.talk (expressive, change every 3.5 s), poses.calm (listening, 25 s), layout
(seam_x; seam_x_guest widens the guest's side while they speak), captions, full_frames,
and optionally music (python scripts/music_bed.py --out music.wav, or a track the user owns).
Preview first: python scripts/render_split.py plan.json --out preview.mp4 --only 40 55, then
python scripts/render_split.py plan.json --out final.mp4 (40 s batches, joined by re-encoding,
frame count checked). Look at frames at each join and measure that the mouth moves during speech.
Step 8b - Polish pass (free, local; ask before each, it is taste)
Do it on a 10-15 s preview first, then show frames. Offer, one at a time:
- No white line:
layout.seam_style: "soft". - Look:
polish.grade,polish.pop(outlined pop-in captions), astyle: "hook"first caption andstyle: "cta"pills for the end cards. - Punch-ins:
polish.punches, a short zoom-pop on the presenter's side for 2-3 punchlines only. The presenter stays still otherwise (users disliked constant zoom or shake). - Fumbles: cut clips where the guest only stumbles; for stretches where she is just playing, set
mute: trueon the clip and put the app's own music underneath (mute_music) instead of silence. - Thought bubbles (
style: "thought") on muted stretches, speech bubbles ("bubble") only for lines she really says. These lines are written FOR the guest: keep them true to what she was doing, give each ~4 s, never pack every cut, keep them inside the claim guide, show the user the exact wording, and let the guest approve it before posting.
Step 9 - Publish (only with an explicit yes)
Label it as AI-generated animation (YouTube: "Altered or synthetic content" = Yes). Post only from the account the user names, and confirm the account name on screen first. Replacing an old post: prefer Private/Archive over Delete, and ask before anything permanent.
Lessons that cost money to learn
- Image models cannot be trusted with hands or arms. Keep real pixels below the neck.
- One avatar reference for every frame, or the character drifts between shots.
- A 429 from Gemini was the monthly spend cap, not a rate limit: tell the user, don't loop.
- Verify every generated asset by looking at it; "ok" from an API means nothing.
- A local ComfyUI / AnimateDiff setup on a 16 GB laptop was too slow and drew the wrong character; keyframes + local compositing is cheaper and better.
- Muting the guest also mutes any app sound in the recording: put music under it, never silence.
- Bubbles that overlap or last under ~3 s are unreadable: one at a time, ~4 s each.
- Batch renders must be joined by re-encoding; stream-copy joins dropped frames and drifted lip sync.