Video Explainer
Input: a topic, article, codebase, or rough notes. Output: a single renders/<slug>-vN.mp4 at 1920x1080 (16:9) and 30 fps (or 9:16 / 1:1 when requested), plus the script.md, media/, and graphics/ files that produced it (pass --share to render.py only when a smaller 720p copy in renders/share/ is requested).
You write the script, narration, and scene code; the scripts fetch media, synthesize voice, align words, compile HyperFrames, render MP4, run 10-check QA, and serve the review page. Commands, script.md syntax, engine APIs, and style.json keys live in reference.md.
On first use, run setup.sh (or setup.sh --voice when using spoken narration). If tools are missing, list them and ask before installing. Put optional GEMINI_API_KEY=... in ~/.config/video-explainer/.env rather than chat.
1. Pick a visual mode
Support three visual modes (Mode: in script.md, default motion):
- Motion (default) (
Mode: motion): Full-frame 2D kinetic graphics, live SVG routes and charts, CSS 3D cards or devices, and documentary press clippings onExplainerStage. Fastest and cheapest. - Illustrated (
Mode: illustrated): Hand-drawn picture-book animation with gouache, pastel, paper grain, 10 fps line boil, and word-synced characters onStoryBrushandIllustratedStage. Uses about 6x the tokens of Motion. - 3D (
Mode: 3d): Single-take Three.js camera flythroughs with studio lighting, bloom, camera-facing labels, and optional Blender meshes onStudio3D. Uses about 7x the tokens of Motion.
If the user already named a mode or asked to run with defaults, proceed immediately (Mode: motion, captions on). Otherwise, show the numbered list above with its token costs, ask whether they want burned-in captions (on by default), and wait for their reply before building.
2. Research, source media, and write script.md
Create one project folder named with a short slug (graphics/, media/, captures/) where the user asks, else projects_dir from style.json, else the current folder.
Verify every claim, number, quote, and step against the user's files or primary sources. Pull real photos, product visuals, clips, or page captures when they ground the story (media.py image, media.py clip, capture.py), and inspect each downloaded image so broken or irrelevant assets stay out of the render. Write script.md:
- Keep runtime to 60 to 75 seconds (2-minute cap). Target
135 to 185spoken words across5 to 8scenes when voiced, or8 to 12beats whenVoice: none(45 to 60s/100 to 150words forAudience: eli5). Stay at or under120s(~260words). When the user asks for another length, write about 2.5 spoken words per second of it and setMax duration: <seconds>. Cut tangents rather than rushing speech. - Default to
Audience: general(smart non-engineer). Use plain English, concrete mental models, and everyday cause-and-effect without raw file paths, internal variable or function names, error codes, CLI flags, or unexplained acronyms in speech or visuals. Switch toeli5(physical metaphors, zero jargon) ortechnical(architecture names, protocols, tradeoffs) only when requested. - Land the hook in 3 seconds and follow one example end-to-end. Open with a concrete question, tension, or number that reads with the sound off, trace one specific request, dollar, star, or user through every step, and close by answering the opening question.
- Write clean spoken copy. Skip throat-clearing openers, binary contrasts, colon reveals, and hype adjectives. Use short sentences and active verbs.
- Set audio and theme headers:
Mode: motion | illustrated | 3d,Audience: general,Voice: kokoro:af_heart(orgemini:Kore, an audio file, ornone),Music: synth:cosmic(synth:warm,synth:minimal, path, ornone),Sound effects: onwith word-anchored## Soundcues (- @s05:iron: rumble 0.8),Captions: auto(oroffwhen the user turned them off), andStyle: default | paper | blueprint.
Go straight from script.md into narration, graphics, QA, and the browser review page unless the user asked to approve the script first or requested a paid Gemini API call without a configured key.
3. Narrate and align
Run narrate.py to synthesize cached per-scene audio, trim dead air, align words with Parakeet, sync start and end times back into script.md, and write work/transcript.md. Read work/transcript.md before coding graphics so animations and sound cues hit exact spoken words via stage.cue("s03", "keyword", 1.2).
4. Build graphics efficiently
Point consecutive rows in ## Scenes at graphics/world.html so build.py mounts one continuous composition and auto-injects stage.css, stage.js, explainer-data.js, plus illustrated.js (Mode: illustrated) or three.min.js and studio3d.js (Mode: 3d).
Build in one agent; the engines are designed for it. The engine APIs and a starter composition per mode are in reference.md.
- Build on the engines. Use
ExplainerStage,StoryBrush/IllustratedStage,Studio3D, andblender_export.pyinstead of writing your own noise, shaders, or mesh packers. - Make it a moving film, never slides. One hero visual fills 60 to 85% of the frame and visibly transforms every 2 to 3 seconds: the camera dives, pans, or draws a live path, and objects morph rather than swap. Cards or text on a flat background with no moving hero visual read as a slide deck. Save the built-in single-beat visuals (
card:,flow:,number:, and the rest) for one-off moments. - Keep labels readable. Callouts are 1 to 4 words (
28px+labels,88px to 160pxhero numbers) with WCAG AA contrast, above the caption band (y < 860on16:9,y < 1400on9:16). - Spend tokens where they show (Illustrated and 3D). Pick one setting and move the camera through it instead of building a new world per scene. In Illustrated, bake each prop and character once and reuse it across scenes. In 3D, use procedural meshes and turn to Blender only when sculpted or fractured geometry clearly adds value.
- Keep every frame deterministic on seek. Bind updates to
stage.onTick/stage.onDrawand end with.finalize(). Load 3D assets synchronously. SkipMath.random()and CSStransformrules on GSAP-animated elements, and putdata-layout-allow-overflowon full-bleed<canvas>or offscreen art.
5. Preview, draft, QA, review, and final
- Token-light pre-flight: Run
render.py "$P" --preview(~3s) and inspect the single tiledwork/preview/contact.jpgfirst to catch framing, contrast, or whiteout bugs. Open individualwork/preview/frame-*.pngfiles only when diagnosing a specific beat. - Draft and QA: Run
render.py "$P" --draftandqa.py "$P". Fix any failed check (10/10required) and inspectwork/qa/contact.jpgandwork/qa/opening.jpg(pluswork/qa/cuts/*.jpgonly around suspect transitions). - Fresh-eyes check before the user sees it:
qa.pymeasures motion, not whether the video looks like slides. Givework/qa/contact.jpgandwork/qa/opening.jpgto a fresh subagent with only the mode and the hook line (judge them yourself if your agent has no subagents), and ask: Does any frame read as a slide, meaning text or cards on a flat background with no moving hero visual? Do the first 15 seconds open on a striking visual that changes every 2 to 3 seconds? Does any art look like generic clip art? Fix every yes, re-render the draft, and check again. - Browser review loop: Start
review.py "$P"in a background shell, share its URL, and runreview.py --poll "$P/work"in the foreground. Apply feedback, re-runnarrate.pyonly if spoken words changed, render--draft, refresh withreview.py "$P" --no-open, runreview.py --ack "$P/work" BATCH_ID, and poll again until approved. - Final delivery: Run
render.py "$P"andqa.py "$P", verify eval.md, ask the user to check voice pacing and mix balance, and report the final.mp4path, duration, and loudness. Offer to save custom theme/caption tweaks to~/.config/video-explainer/style.json.