Animated story short (three.js + Remotion + Kokoro)
template/ is a complete, working project: the short The Coin on the Doorstep (13 shots, 2 characters, 54 s).
Every new short starts as a copy of it. You keep the engine and rewrite the story parts.
Story, characters and voice are always the user's OWN. Never copy an existing channel's characters or scripts.
Before you start
- Work in the user's project folder. If it has no
src/videos/, copy everything intemplate/into it. - Check Node.js 20+, Python 3.11 and ffmpeg. Install what is missing (ask first if it needs a password).
npm install(versions inpackage.jsonare pinned on purpose, see Gotchas).- Python: create
.venv, thenpip install -r requirements.txt. Always run Python as.venv/bin/python. - Default to 1080x1920, 30 fps, captions on, GPU rendering. Follow the user's request where it differs.
Pipeline
- Story →
story/story.txt. About 110-125 words (≈50 s). Hook question in the first 2 seconds, 2 characters, ONE place, one twist at the end, short sentences. Write it so it can be staged with two people standing in one street: every extra location costs a new set. If the user gave no topic, pick one and say so. - Voice →
.venv/bin/python voice_words.py story/story.txt a af_heart. Writesvoice/voice.wavandvoice/words.json(start/end time of every word; Kokoro gives these for English). Copyvoice/voice.wavtopublic/only if a composition needs it; the final audio is muxed with ffmpeg. - Shot plan in
src/videos/<name>/story.ts(copysrc/videos/coin/to a new folder and register it insrc/Root.tsx):W: the cue words and their times, read fromwords.json.TOTAL: frames = audio seconds x 30.SHOTS: one per story beat, frame range, lightday/golden,sunDir.CAMS: per shot, keys{f, dur?, cut?, s}. Cut on big jumps, glide 18-30 f otherwise, every hold creeps in.KICKS(impact shakes),DOF(lens blur per beat, focus on the eyes),XFADE,FLASH_AT.- Every visual reaction lands 0-3 frames BEFORE its word.
- Keep faces in the upper half: captions own the band at 68-80 % of the height.
- Cast in
cast.ts: outfits (Outfit), then one function per character that returns pose, expression, look direction and blink for a shot id and time. 14 expressions exist intoon.ts(Expr). Coins, bubbles, bursts and twinkles are small canvas drawings pushed asfx. Use the SAME outfit options in front and side view (dressis drawn in front view only). - Set in
world.ts/build.ts: the town, river and bridge are already there. Add only what the story needs (the template adds a picket fence, a broken-window decal and six hand-placed houses on the far-bank main street, x = -6..6, z = 47..76). Houses, trees and hedges are procedural; no model files are needed. - Test frames before anything else.
node scripts/stills.mjs out/s_ 20,300,800 0.5, thenpython3 scripts/sheet.py out/sheet.jpg 5 out/s_*.jpgand LOOK at the sheet. Render one frame first: if it is blank, fix that before building (see Gotchas). Check every shot: subject in frame, nobody cut off, faces lit, nothing covered by captions. Fix and repeat until clean. - Captions: build
captions.jsonfromwords.json(pages of 1-3 words, max ~15 letters, break at punctuation and pauses).Captions.tsxdraws them; the spoken word is yellow. - Sound →
.venv/bin/python scripts/sound.pywritesout/mix.wav: the voice, an original synthesized tune ducked under speech, and effects placed on cue words. Edit the cue list for the new story. Nothing is sampled, so nothing needs a licence. Lock picture timing before making sound. - Render on the GPU:
npx remotion render src/index.ts <Comp> out/video.mp4 --gl=angle --hardware-acceleration=if-possible --codec=h264 --video-bitrate=16M --concurrency=3then mux and set loudness for YouTube:ffmpeg -y -i out/video.mp4 -i out/mix.wav -map 0:v:0 -map 1:a:0 -c:v copy -af "loudnorm=I=-14:TP=-1.5:LRA=7" -ar 48000 -c:a aac -b:a 192k -shortest -movflags +faststart output/short-1.mp4 - Check the result:
ffmpeg -i output/short-1.mp4 -vf "blackdetect=d=0.05:pix_th=0.05,freezedetect=n=0.001:d=0.4" -af ebur128 -f null -(no black or frozen spans, about -14 LUFS), plus a contact sheet of the whole video. Tell the user plainly what you checked and that you cannot hear the audio. - Deliver the mp4 and list anything that differs from what they asked.
Another language (proven for Hindi)
Keep the picture. voice_hi.py holds the translated story as phrases, each with the start time of its English phrase
and the latest time it may end. It speaks each phrase with Kokoro (lang_code="h", voices hf_alpha, hf_beta,
hm_omega, hm_psi), speeds a phrase up only if it overruns (cap 1.25x; shorten the wording instead of going
faster), and writes voice/voice_hi.wav plus captions_hi.json. Kokoro gives no word times outside English, so
caption words are spread across each phrase by length. Then:
.venv/bin/python scripts/sound.py voice/voice_hi.wav out/mix_hi.wav, render with --props='{"lang":"hi"}', mux.
Drop narration the picture already shows ("he shouts", "she whispers") to win time.
Gotchas (all hit while making the template)
- Blank frame: the
@react-three/postprocessingwrapper renders nothing with React 19 / R3F 9.Bridge.tsxdrives postprocessing's ownEffectComposerby hand insideuseFrame. Keep it that way. - three must stay at 0.176.0: newer versions removed shadow features this engine uses.
- 404 messages for
kenney/*.glbare harmless: those models are optional. - A low sun behind a house row leaves every face in violet shade. Give each shot a
sunDirthat shines along the open street (template:SUN_DAY,SUN_GOLD). - A 9:16 frame is narrow: two characters must stand within ~3 m, or the camera must sit 9+ m back.
- Characters are flat cards that always face the lens. There is no back view: when the story needs someone to look at something behind them, cut to that thing alone.
- To hide a body behind a fence, lower the card (
y) so the ground swallows the legs. - Devanagari captions: font
Kohinoor Devanagari, no negative letter spacing. - ffmpeg builds without
drawtextexist (Homebrew default): do not rely on burned-in frame numbers. - A full 54 s render takes about a minute on an Apple M3 with the GPU.
Credits
The engine (world, characters, ink, lens blur, grade) comes from the MIT-licensed "Claude Animated Shorts" skill by
Mr omi. This skill is a fixed and extended working copy of it with a new example short, captions, Kokoro word
timing, a Hindi path and a sound script. Keep LICENSE when you share it.