From Textbook Chapter
to Sci-Fi Film
Part 1 decoded what makes great educational YouTube work. Part 2 is the generation side: a 7-stage pipeline that takes a dry textbook chapter — table of contents, sub-topics, equations — and produces a cinematic short film that actually teaches the material. Not slides. Not a voiceover over PDF pages. A movie.
Textbooks are precise but emotionally inert. The best YouTube educators — the ones we analyzed in Part 1 — succeed because they wrap ideas in narrative, character, and visual rhythm. The ideal end state isn't "AI-generated Khan Academy." It's production-quality films where the math is the plot.
🎬 The Core Idea
Take a textbook chapter — say, Complex Numbers from an intermediate mathematics syllabus — and transform it into a science-fiction short film. Three recurring characters navigate a real problem. When the story demands it, the film cuts to a precise Manim visualization of the concept. The viewer learns the chapter not by reading it, but by living inside it.
"M poses the real problem → Y and F work it out → F teaches Y via cinematic scenes → one high-level Manim insert per concept → back to story. The math is never explained before the viewer has a reason to need it."
— Pipeline design principleEvery chapter shares the same cast and visual world. Characters are locked at series setup — reference photos, voice profiles, and visual grammar are built once and reused across all chapters.
The Series Bible (Stage 3) locks everything: character descriptions, voice profiles, world premise, set designs, camera rules, color grade, and a multi-angle reference photo bank per character. Flux keyframe generation uses these references to keep identity consistent shot-to-shot, chapter-to-chapter.
Every scene in the screenplay is tagged with one of three types. This determines which generation path handles it downstream.
core_visual_idea. No derivations, no scope creep. Shows the one thing the viewer must see to understand the concept.
Text stages run first on Qwen via vLLM. GPU-heavy pixel generation runs only after all upstream text passes quality gates.
Each stage writes to a dedicated output/ subdirectory — never mixing artifacts.
Stages 5a (cinematic video) and 5b (Manim) run in parallel after the storyboard is locked. Stage 6 reconciles timing across all assets. Stage 7 assembles everything into the finished film.
Each stage has a dedicated script, prompt template, quality gate, and output directory. The orchestrator (run_pipeline.py) chains them with gate checks.
core_visual_idea for the Manim insert.
Explicitly marks what to exclude — no scope creep downstream.
python3 scripts/generate_math_bible.py \
--input scripts/samples/input_docs.md
python3 scripts/build_reference_bank.py --copy-only
python3 scripts/generate_storyboard_keyframes.py --skip-existing
core_visual_idea locked at Stage 1.
Qwen writes Manim code → render → Gemma 4 reviews visuals and code → fix loop until pass.
Hard rule: if scope creeps here, it's a Stage 1 problem, not a Manim problem.
Qwen plans and judges. Gemma looks at pixels. GPU generation runs last. The rule keeps expensive compute off bad upstream text.
⚡ Running the Full Pipeline
Start Qwen vLLM once, set environment variables, then orchestrate:
python3 scripts/run_pipeline.py --dry-run
# Text stages (1 → 4)
python3 scripts/run_pipeline.py --from-stage 1 --to-stage 4
# GPU pixel stages + audio + assembly
python3 scripts/generate_storyboard_keyframes.py --skip-existing
python3 scripts/generate_cinematic_videos.py --skip-existing
python3 scripts/generate_manim_videos.py --skip-existing
python3 scripts/generate_audio.py
python3 scripts/assemble_final_cut.py --chapter-slug complex_numbers
The pipeline doesn't blindly chain LLM outputs. Each stage has a gate — automated review, manual sign-off, or both — before the next stage is allowed to run.
run_pipeline.py reads gate results from output/pipeline/gates/ and refuses to proceed on failure. Use --force only for development.Part 1 measured what great educational video looks like. Part 2 is the factory that builds it. The DNA dimensions become concrete generation targets:
Narrative DNA — sentence length, information density, curiosity-gap patterns — trains the script adapter that transforms math topics into creator-voice dialogue.
Vocal DNA — speech rate, pause distribution, prosody — sets TTS performance targets for each character's delivery cadence.
Visual DNA — scene duration, visual richness, shot tempo — constrains storyboard shot counts, keyframe detail level, and cut rhythm.
Structural DNA — shot budgets, scene-type sequences, video length distributions — guides the editor's assembly pattern toward creator-authentic pacing.