Audio-to-Animated-Story Video (HyperFrames Data-Driven Pipeline)
Overview
Turn any long narrated audio file into a complete, narration-synced animated HyperFrames video series using one reusable data-driven engine + compact per-part JSON, keeping AI token usage minimal and rendering 100% offline.
Core principle: Separate reusable motion/layout code (written once from bundled templates/) from per-story art (characters.svg, backgrounds.js) and per-part story data (data/partXX.json). Never hand-write per-scene HTML, never spawn parallel episode subagents, and never burn tokens on PNG snapshot loops or inline batch rendering.
Quick Reference
| Phase | Artifact Produced | Token / Runtime Rule |
|---|---|---|
| 0. Align | Aspect ratio (16:9 default), art style, subtitles (off default) | Ask before drawing rigs or backgrounds |
| 1. Audio & Text | audio/chunks/partXX.m4a + transcripts/parts_compact/partXX.txt | Transcribe once; compact start-end|text local 0..300s |
| 2. Core & Art | engine/ + assets/characters.svg + scripts/ | Copy templates/; author only story rigs & backgrounds |
| 3. Pilot Gate | build/part01 live in HyperFrames Studio | Real copied assets/ (no junctions); wait for user approval |
| 4. Author JSON | data/part01.json .. data/partNN.json | Single session; batch-read 3–4 transcripts, batch-write 3–4 JSONs |
| 5. Build & Check | build/part01/ .. build/partNN/ | node scripts/build-series.mjs all + Node validator (node --check) |
| 6. Render | renders/partXX.mp4 + renders/full_story.mp4 | Hand user offline render-all.ps1 (0 AI tokens) |
Step-by-Step Pipeline
Step 0: Align Before Generating Assets
Before writing rigs or backgrounds, confirm three items with the user if not already stated:
- Aspect ratio: Default
16:9(1920×1080, 30 fps); confirm if9:16is wanted instead. - Visual style & genre: Period/culture, color palette, and cast list.
- Subtitles / title card: Default no subtitles (only an opening title card on Part 01 Scene 1).
Step 1: One-Time Audio Split & Compact Transcription
- Slice the master audio into ~5-minute chunks (
300s) usingffmpegintoaudio/chunks/part01.m4a..partNN.m4a. - Transcribe once and convert to compact part-local text files
transcripts/parts_compact/partXX.txt, one line per cue with local timestamps (0to chunk duration):0-4.3|Narration line one 4.3-10.7|Narration line two - Never re-run Whisper or re-slice audio if
audio/chunks/andtranscripts/parts_compact/already exist.
Step 2: Copy Bundled Templates & Author Story Art
Copy all 5 files from this skill's templates/ directory into the project:
templates/engine.js→engine/engine.jstemplates/fx.css→engine/fx.csstemplates/anim-helpers.js→assets/anim-helpers.jstemplates/build-series.mjs→scripts/build-series.mjstemplates/render-all.ps1→scripts/render-all.ps1
Then author ONLY the two story-specific art files:
assets/characters.svg(and compiledassets/characters.js):- Mandatory Parent-Child Rig Hierarchy: Nest
.part-head, back-hair,.part-arm-l, and.part-arm-rinside.part-torsoso bowing or tilting never detaches heads, hair, or arms from the body. - Center every character around
x=160inviewBox="0 0 320 480"with feet aty=455. - Record each character's
[eyeY, mouthY]inFACE_Yinsideengine/engine.jsso universal facial emotions align pixel-perfectly.
- Mandatory Parent-Child Rig Hierarchy: Nest
engine/backgrounds.js:- Export
window.KCBackgrounds = { ids, build, crowd, prop }. - Provide 10–16 reusable layered backgrounds (
{ far, mid, near, front }). - Provide dense background crowds (
crowd) of 6–8 depth-scaled figures pushed to the far left/right wings (x=35..360andx=1480..1800,opacity: 0.74) so they frame scenes without overlapping foreground actors. - Provide reusable iconic set-piece
props (rituals, thrones, altars, weapons, vehicles,bridal-bed, etc.) instead of writing bespoke per-scene HTML/SVG files.
- Export
Step 3: Pilot Preview Gate (Before Full Series)
- Author
data/part01.json(or a 2-minute pilot) and runnode scripts/build-series.mjs part01. - Windows Studio Asset Rule:
build-series.mjsMUST copyassets/as a real local directory inside eachbuild/partXX/assets/. NEVER usemklink /Jjunctions ormklink /Dsymlinks — HyperFrames Studio rejects realpaths resolving outside the project root with403 Forbidden. - Launch HyperFrames Studio preview for the user and wait for visual approval before authoring the remaining parts:
(Ornode .agents/skills/hyperframes/scripts/plugin-cli.mjs preview build/part01 --port 3003npx hyperframes preview build/part01 --port 3003if installed globally/locally.)
Step 4: Single-Session Data-Driven JSON Authoring
Author data/part01.json .. data/partNN.json directly in the main session in parallel batches of 3–4 files (read 3–4 partXX.txt files in parallel → write 3–4 data/partXX.json files in parallel).
Scene JSON Contract (data/partXX.json):
{
"dur": 300,
"scenes": [
{
"start": 0,
"end": 14.5,
"bg": "village-day",
"char": ["char-hero", "char-heroine", "char-rival"],
"pose": ["talk", "idle-breathing", "enter-right"],
"enterAt": [0, 0, 5.2],
"mood": ["happy", "love", "angry"],
"crowd": "villagers",
"prop": "offering-tray",
"staging": "courtship",
"fx": ["fade-in", "petals", "vignette"],
"cam": "zoom-in"
}
]
}
Required Scene Authoring Rules:
- Granularity: Aim for 14–24 crisp scenes per 5-minute part (
~8–20seach). Split a new scene whenever the location or character group changes — never cram two unrelated locations into one scene. - Unlimited Cast: Never artificially cap characters at 2 or 4. Include every named character present in the narration;
engine.jsautomatically spaces 1–7 characters in a wide row and 8+ characters into a 2-row depth layout. - Exact
enterAtSync: Whenever a character is mentioned mid-scene, setenterAt[k]to the exact relative seconds (cueTime - scene.start).anim-helpers.jshides late entrants withgsap.set(..., { opacity: 0 })outside the timeline so they never flash visible att=0. - Contextual Emotions (No Constant Mouth-Flapping): Use
mood(calm,happy,love,sad,angry,shock,smirk,stern) for eyebrows, mouth shape, blush, teardrops, or sweat drops. Do NOT add continuous talking mouth-flap loops. - Delicate / Iconic Scenes: Use reusable
staging+propcombinations:- Courtship:
"staging": "courtship"+ warm glow prop (brings pair closer[760, 1160], tender lean-in,lovemood). - Intimate / bridal chamber (tasteful, YouTube-safe):
"staging": "intimate"+"prop": "bridal-bed"(pair moves into embrace, silk bed curtains sweep closed, oil lamp dims). - Rituals / trials / battles: use dedicated animated set-piece props (
.prop-flame,.prop-wisp,.prop-spark, etc.).
- Courtship:
- Walk & Tween Safety: Clamp walk travel distance by cast size (
engine.jsenforcesmaxD) so characters never collide; startkneel-bowafterrevealfinishes (t0 + 0.75s) whenenterAt > 0.
Step 5: Deterministic Build & Fast Zero-Chrome Verification
Run the builder and a single fast Node verification pass:
node scripts/build-series.mjs all
Verify programmatically (takes <2 seconds, 0 Chrome instances, 0 vision tokens):
node --checkpasses on everybuild/partXX/{data,engine,backgrounds}.js.- Zero timestamp gaps (
|scene[i].start - scene[i-1].end| <= 0.05) and finalend === dur. - Every
char,bg,crowd,prop,pose,fx,cam,moodID is valid andenterAt.length === char.length. - Every
build/partXX/assets/audio/partXX.m4aexists.
Step 6: 0-Token Offline Sequential Rendering
NEVER render all parts inline inside the AI conversation. Give the user the offline script command:
powershell -ExecutionPolicy Bypass -File scripts\render-all.ps1 -StartPart 1 -EndPart 9 -Concat
render-all.ps1 auto-detects FFmpeg & HyperFrames CLI, renders one part at a time with --low-memory-mode --quality looks (safe for 16 GB RAM laptops), skips already-rendered MP4s for instant resume, writes a UTF-8 without BOM concat.txt, and concatenates via ffmpeg -f concat -safe 0 -i concat.txt -c copy.
Strict Prohibitions & Red Flags
| Temptation / Rationalization | Why It Fails | Required Rule |
|---|---|---|
| "Spawn 4–10 parallel subagents to finish episodes faster" | Burns 5–10x tokens, hits 429 RESOURCE_EXHAUSTED, causes inconsistent style | Author all data/partXX.json in the main session in parallel file-write batches |
| "Write custom HTML/SVG per scene for higher quality" | Explodes token count and breaks maintainability | Keep 1 shared engine.js + reusable prop/staging set-pieces + compact JSON |
"Run hyperframes check --snapshots & inspect 3–4 PNGs per scene" | Spawns 599 Chrome samples per part and burns 100k+ vision tokens | Use node --check + Node JSON validator + user Studio preview on Part 01 |
"Use mklink /J junctions to share assets/ on Windows" | HyperFrames Studio returns 403 Forbidden for paths resolving outside project root | Always copy real assets/ directory per build/partXX/ |
"Add rhythmic mouth-flapping lip-sync during talk" | Looks distracting and robotic over narration | Use static contextual facial mood + subtle head/hand gestures only |
| "Render all parts sequentially inside this agent session" | Burns tokens polling/waiting and risks shell timeouts or OOM | Deliver scripts/render-all.ps1 with --low-memory-mode for 0-token offline rendering |
| "Cap characters at 2–4 so layout is simpler" | Drops named characters mentioned in narration, breaking story accuracy | Support unlimited char with automatic wide-row (5–7) and 2-row (8+) layout |