Communitygithub.com

lecture-video

Turn lecture notes, slides or textbook chapters into a series of short, animated, narrated explainer videos (3Blue1Brown-style), using the single-file lecture_video.py package (matplotlib animation + offline Piper TTS + parallel H.264 rendering). Use when the user asks for explainer videos, animated revision videos, narrated walkthroughs, or "videos from my notes/slides".

What is lecture-video?

lecture-video is a Claude Code agent skill that turn lecture notes, slides or textbook chapters into a series of short, animated, narrated explainer videos (3Blue1Brown-style), using the single-file lecture_video.py package (matplotlib animation + offline Piper TTS + parallel H.264 rendering). Use when the user asks for explainer videos, animated revision videos, narrated walkthroughs, or "videos from my notes/slides".

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Jin-underworld/Lecture-Video-Builder/tree/HEAD/skills/lecture-video

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Lecture → animated explainer videos

You drive lecture_video.py, a single Python file. A lesson is a Python module that defines LESSON = Lesson(code, title, beats). Each beat is a tuple (say, draw_fn[, hold]). Piper speaks say, and draw_fn(L, f) draws every frame while it is spoken. The package handles timing, rendering, muxing and verification. README.md next to lecture_video.py documents the full API, so read it once before you write your first lesson.

0. Locate and check the tools

  1. Find lecture_video.py. Look in the project, then the repo this skill came from, or ask the user. Run python lecture_video.py doctor.
  2. Look for a Piper binary and voice (.onnx + .onnx.json). Ask the user where they are if they aren't obvious. Without them you can still produce silent previews with --tts none.
  3. You need an encoder: ffmpeg, or else OpenCV plus gcc/pkg-config/libav-dev on Linux. Ask before installing anything large. If a tool is missing, look for it first: other Python installs, WSL distros, conda envs. Prefer a different environment that already has the tools over installing new ones.
  4. On Windows the fallback encoder needs Linux, so run the tool inside WSL. WSL argument passing breaks on paths with spaces, so create a symlink to the work folder that has no spaces.

1. Survey the source material

  • Extract text from the PDFs or slides (pdftotext -layout, or the PDF reading tool). List each section's slide titles, key equations, worked examples and the problem-set questions.
  • Note which parts are mechanisms (anything that moves, flows, rotates, switches or evolves in time). Those become animations. Static facts become short text and equation builds.

2. Propose an outline before heavy work

Propose a series of 3–5 minute videos, one coherent topic each, usually 8–12 beats and 550–800 words. Give titles and a one-line scope for each, plus the total count and runtime. Wait for approval (or proceed if the user said to). Make one pilot video first, send it, and ask about the look and pace before you batch the rest.

3. Write each lesson (one .py per video)

Structure: a hook/title beat; one beat per idea; one or two worked examples taken from the source (problem sets and class examples); and a recap beat. End with a pointer to the next video.

Narration rules (Piper reads literally):

  • Write maths in words ("V over R", "omega", "ten to the minus three"). Spell out abbreviations as they should be spoken ("D C", "r p m").
  • About 160 words a minute. One beat is 35–70 words (about 15–25 s).
  • If the user gives a name, address them by it in the first beat.
  • Compute every number with code before writing it into say or on screen. Cross-check it against any provided solutions. Tell the user if the source material contains an error.
  • For "try it" questions, add a hold of a few seconds to that beat.

Animation rules:

  • Draw from state: derive positions, angles and values from f.t (closed form, or a precomputed table at module level). Never keep state between frames, because beats render in parallel.
  • Schedule appearances with t0 values inside the beat. Keep key events in the first ~80% of f.T, since beat lengths vary slightly after TTS.
  • Layout: the mechanism on the left or top, equations in a right-hand panel (x ≈ 1–7), graphs below. Leave about 0.4 units from the frame edges. Use colour to tie a symbol to its arrow or curve.
  • Use f.tex for anything mathematical. Put glyphs the text font may lack (∝ ∥ ∠ ✓, combining overlines) in f.tex as well.
  • Show mechanisms moving: rotating fields, flowing current arrows, growing graphs with a dot at the tip, live numeric readouts, before/after comparisons with parameters sweeping.

4. Check layout before rendering

python lecture_video.py stills lesson.py        # uses estimated timings if not narrated yet

Look at videos/frames/<code>_sheet.png with the image reader. Fix overlaps, clipped text, labels sitting on lines, glyph boxes (□) and anything off-screen. Repeat until it is clean. A still is taken at 85% of each beat, so also reason about earlier moments.

5. Narrate, render, verify

python lecture_video.py build lesson1.py lesson2.py --piper PIPER --model VOICE.onnx
  • build = narrate + render + verify. Use render after changes to visuals only. Use narrate (or build) after any change to say, or after adding or removing beats.
  • Run long renders in the background. Render one lesson at a time and keep --workers at 8 or below, because each worker's 1080p encoder uses about 1 GB of RAM. If a render stalls or the machine starts swapping, kill it and lower --workers.
  • When chaining jobs ("wait for X, then run Y"), never wait with pgrep -f <pattern> from a shell whose own command line contains that pattern, because it matches itself forever. Chain commands with && in one job instead.
  • Confirm every video prints verify ... OK (a difference of a few hundredths of a second is fine). Spot-check frames from the MP4 itself, not just the stills.

6. Deliver

Send the pilot first, then the full set with:

  • a suggested viewing order,
  • what each video covers,
  • any errors found in the source material,
  • where the files and lessons live, and how to re-render one after an edit.

Do not include the user's course material in anything they plan to publish unless they ask.

Reference: the most-used Frame calls

f.k(t0,d) f.lin(t0,d) f.out(t1,d) · f.text(x,y,s,size,color,t0,ha,bold) f.tex(x,y,r"..",size,color,t0,ha,box=(c,t0)) f.eqs(x,y,[..],t0,stagger) · f.line/path/arrow(p,q,grow=)/head/arrow_on f.rect/circle/ellipse(th1,th2)/poly/wedge f.box · f.axes(ox,oy,w,h,xlab,ylab) f.plot(ox,oy,w,h,fn,xr,yr,upto=) f.grid_marks(..,kind) · f.title_card(kicker,title,sub) f.recap(rows,footer).

Related Skills