Communitygithub.com

doc-to-video

Turns documents, papers, lecture notes or outlines into narrated explainer, lecture, revision or tutorial videos with slides, charts, offline voiceover, subtitles and chapter markers. Use when asked to "make a video from this document", "turn my notes into a lecture video", "make an explainer video" or "narrated slides", and prefer it over general video skills for any slide- or chart-based video.

Was ist doc-to-video?

doc-to-video is a Claude Code agent skill that turns documents, papers, lecture notes or outlines into narrated explainer, lecture, revision or tutorial videos with slides, charts, offline voiceover, subtitles and chapter markers. Use when asked to "make a video from this document", "turn my notes into a lecture video", "make an explainer video" or "narrated slides", and prefer it over general video skills for any slide- or chart-based video.

Funktioniert mit✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/rafaefarrukh/vidkit/tree/HEAD/skills/doc-to-video

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Doc to video (vidkit)

For any video built from slides, diagrams and charts with a voiceover or captions: lectures, revision videos, explainers, tutorials, data stories. The engine (vidkit.py, in this skill's folder) measures real glyph widths, sizes cards to their content, places chart labels clear of the data, lints every scene as text, and renders narrated chapters with soft subtitles and chapter markers. Voiceover is generated locally with Kokoro TTS; nothing is sent to a TTS service.

Rules

  1. Length first. Narration runs at about 125 words per minute including pauses, so words per chapter = target minutes × 125. Plan 2 to 2.5 scenes per minute. Write to the budget the first time: every trim costs another lint pass.
  2. Scenes as data. Use the built-in kinds (title, cards, table, flow, statement) for anything that is text. Write a custom draw only for real charts or diagrams, and keep it short. A scene with only a few short items looks empty however it is laid out: add a chart or merge it with the next scene.
  3. Compute before you narrate. Generate every dataset and print every number a scene will show or say in one script run, then narrate from the printed values. For figures from a source document, extract its tables once (pdftotext -layout) and print the values each scene uses as one listing.
  4. Fix from text, not images. Lint reports every problem as a line. Fix until issues=0, then open the chapter's one contact sheet once to judge the design. Never render to check layout, and open individual stills only if the sheet shows a specific problem.
  5. Few calls. Every tool call re-reads the whole context, so cost scales with the number of calls. Write each spec in one Write, lint several chapters in one command, never re-lint a clean chapter, combine checks into one shell call, and print only summary lines, never whole logs.
  6. Never load whole documents (sources or design systems) into the conversation; extract what you need with a command.

Workflow

1. Outline, then wait for confirmation

If the source is a document, extract it with a command and read only what the outline needs. Then send one message with:

  • Chapters and scenes: each scene's kind and a one-line description; for a custom chart, what is plotted against what.
  • Length: target minutes (the user's, if given) and word budget per chapter, plus the total.
  • Theme (step 3), output (one MP4 with chapter markers and soft subtitles) and whether companion files (notes, PDFs) are wanted, since each is extra work.
  • Voice, as one line: "Voice: British male (George). Others: British female (Emma, Isabella, Alice, Lily), British male (Fable, Lewis, Daniel), American female (Heart, Bella, Nova, Sarah, Nicole…), American male (Adam, Michael, Eric, Onyx, Liam…), plus Spanish, French, Hindi, Italian, Japanese, Portuguese and Mandarin. Want a different one?"
  • Run mode, as one line: "Run mode: auto (I do everything and send the finished video) or step-by-step (I stop after chapter 1, after all chapters are linted, and after rendering, so you can approve or ask for changes; each stop adds a little usage)?"

End with one question: confirm (with a run mode), or say what to change. Run no setup and write no spec until the user confirms. If the reply does not choose a run mode, use auto. After confirmation, create a task list (setup → specs → lint → render → merge → deliver) and start.

Auto: go through every step without stopping and send only the finished video. Stop early only for a decision the outline did not settle (for example, the source contradicts the plan).

Step-by-step: stop at three checkpoints, and continue only after the user approves. Apply any requested changes before moving on, re-lint only what changed, and show the result again only if the user asks.

  1. After chapter 1 is linted: send its contact sheet with its reported length and word count against the budget.
  2. After all chapters are linted at issues=0: send the remaining contact sheets (stacked into one image) and the total length against the plan.
  3. After rendering, before merging: send the shortest chapter MP4 as a sample and list the chapter lengths; merge and deliver once approved. Send each checkpoint with SendUserFile and one line of context, then end the turn with a single question (approve, or say what to change).

2. Setup (one command)

python3 "${CLAUDE_SKILL_DIR}/setup.py" ~/vidkit

If ${CLAUDE_SKILL_DIR} is not replaced, use this skill's base directory (shown when the skill loads). On Windows, use python instead of python3 here and below. Setup copies vidkit.py into ~/vidkit, installs the Python packages, downloads the fonts and the voice model (about 350 MB, once), checks for ffmpeg, ffprobe and pdftotext, and prints the CPU count and how many renders to run in parallel. It is safe to re-run. If it ends with SETUP INCOMPLETE, show the user the install commands it printed and wait; ffmpeg is required, pdftotext only for PDF sources. If TTS cannot run, use silent scenes (Other formats).

3. Theme

Default (no step needed): the built-in light theme (plum accent, mauve neutrals, Lexend headings, Ubuntu body). If the user names no design system, specs need no THEME or FONTS.

A design system or brand (a file, a site, a link, or colours in words):

  1. Extract tokens only, never the whole document: e.g. grep -oiE '#[0-9a-f]{6}\b|--[a-z0-9-]+: *[^;]+' tokens.css | sort | uniq -c | sort -rn | head -40. If the source is only reachable through a tool that returns whole files into the conversation, save it to disk first and grep that. Colours given in words are the tokens.
  2. Map them once into ~/vidkit/theme.py; each spec does from theme import THEME, FONTS:
THEME = dict(bg="#fbfaf7", surface="#ffffff", soft="#eef1f6", fg="#1b2230", muted="#545d6e", border="#d9dee7",
             strong="#7d8697", accent="#1f3a68", accent_line="#a9b9d6", good="#2d6a3e", good_soft="#e3efe5",
             bad="#8a2b36", bad_soft="#f6e3e5", grid="#eef0f4", axis="#d9dee7", data="#9aa3b2",
             series=["#1f3a68", "#e07a2e", "#3f8fa0", "#b5525e", "#2b2f3a", "#e9c46a"])
FONTS = dict(display="fonts/Brand-Display.ttf", body="fonts/Brand-Regular.ttf",
             body_medium="fonts/Brand-Medium.ttf", body_bold="fonts/Brand-Bold.ttf")   # omit to keep the default fonts

Slots: bg page, surface card fill, soft highlighted fill, fg/muted text, border/strong lines and arrows, accent/accent_line emphasis, good/bad (+ _soft fills) right and wrong, grid/axis/data chart chrome and neutral data, series chart colours. Fill unmapped slots with tints or shades of the brand's colours. 3. Brand fonts in Google's open collection: download from https://raw.githubusercontent.com/google/fonts/main/ (ofl/<name>/… or ufl/<name>/…; brackets as %5B/%5D) into ~/vidkit/fonts, and instance variable fonts to one weight with fontTools.varLib.instancer. Otherwise keep the defaults or the closest open font, and say which in the outline. 4. Lint reports contrast issues for unreadable theme pairs; fix by darkening text or lightening fills, keeping the brand hue.

4. Specs: chapter 1 first, then the rest

Write specs in ~/vidkit. Write and lint chapter 1 alone, compare its reported minutes with the plan and adjust the word budget, then write the remaining chapters (one Write each).

# ch1.py
import numpy as np
from vidkit import T, label            # T = theme colours; label = data-avoiding chart label
NAME = "ch1"; TITLE = "1. Foundations"; EYEBROW = "Chapter 1 · Foundations"   # TITLE = chapter marker in the merged file
VOICE = {"voice": "bm_george", "lang": "en-gb", "speed": 1.0}                  # optional
rng = np.random.default_rng(1); x = rng.normal(0, 1, 120); y = 0.7 * x + rng.normal(0, .6, 120)

def scatter(cv, s):                    # custom draw: charts and diagrams only
    a = cv.chart(110, 230, 1000, 600, alpha=s.p(0))
    a.scatter(x, y, s=30, color=T["data"])
    if s.p(1) > 0: label(a, x[y.argmax()], y.max(), "highest point", color=T["accent"], px=18, alpha=s.p(1))
    cv.para(1180, 260, "Labels search for a spot clear of the data.", 640, 28, maxh=200, alpha=s.p(2))

SCENES = [
  dict(kind="title", heading="Exploratory data analysis", sub="Why it comes before any model.", kicker="Chapter 1",
       lines=["Chapter one. Exploratory data analysis."]),
  dict(kind="cards", title="Two kinds of tools", cols=2, accent=(1,),
       items=[("Graphical", "histograms, box plots, scatterplots"), ("Numerical", "mean, median, SD, IQR")],
       lines=["E D A uses two kinds of tools.", "Graphical ones show structure.", "Numerical ones quantify it."]),
  dict(kind="custom", title="A chart", draw=scatter, lines=["A scatter.", "Label the top.", "Add a note."]),
]

Scene keys. lines: narration, one sentence per entry; sentence k's start is cue k. title, eyebrow (override), draw (extra drawing on any kind), region (x, y, w, h for cards and tables; default BODY = (96, 210, 1728, 820)), sig (see Timing). Items in cards, table and flow appear at at[i], which defaults to cue i+1 (sentence 0 introduces the scene), so these scenes need one more sentence than items.

  • cards: items [(head, body)], cols, accent (indices), at. Cards size to their text; the font scales 0.65 to 1.5×.
  • table: header, rows, colfrac, hl (highlighted rows), at. Font fits between 16 and 40 px.
  • flow: steps, accent, at, note, note_at, y, bh.
  • statement: big, small, small_at. title: heading, sub, kicker.

Custom draw API (canvas 1920×1080, origin top-left; the title occupies y < 180; keep 96 px side margins):

  • cv.text(x, y, s, px, role, color, ha, alpha): role display, body, body_medium or body_bold; y is the baseline.
  • cv.para(x, y, s, maxw, px, role, color, alpha=, maxh=): wraps by measured width, returns height, lints overflow past maxh. Use it for every multi-word string.
  • cv.math(x, y, r"$...$", px) (matplotlib mathtext, parse-checked), cv.box, cv.rect, cv.line, cv.arrow, cv.circle.
  • cv.chart(x, y, w, h, alpha=): a matplotlib Axes in a pixel box; alpha fades the whole chart. Leave about 60 px below it for tick labels.
  • label(ax, x, y, s, color, px, alpha): data label that avoids points, lines, bars and other labels. Call it after plotting all data; never use ax.text at a data coordinate.
  • fit_block(cv, x, y, w, h, s, role, px0): largest font that fits a box.

Timing. s.p(k) eases 0→1 over 0.55 s from the start of sentence k (use as alpha or offset); s.p(k, delay=0.3*i) staggers; s.lin(k, dur) is linear progress; s.cue() is the current sentence. Frames re-render for 3.2 s after each cue and are reused otherwise, so anything that changes later than that (a 9-second sweep, a mode switch) needs sig=lambda s: (round(s.lin(1, 9.0), 3),) in the scene.

5. Lint

cd ~/vidkit && nohup sh -c 'python3 vidkit.py lint ch2.py ch3.py; echo ALLDONE' > lint.log 2>&1 &
python3 ~/vidkit/vidkit.py wait ~/vidkit/lint.log ALLDONE

Run the wait line with a 10-minute tool timeout; it prints only status lines, and if it says STILL RUNNING, run it again. One lint call takes several chapters and loads the voice model once. Issue kinds: overflow; glyph (character missing from the font, e.g. arrows, check marks, x̄: write words or use cv.math); mathtext (use \leq, \geq, \mathrm{}; no \text{} or \underbrace); offcanvas; text-overlap; label-on-data; label-overlap; contrast; cue (an index at or past the number of sentences, so the element never appears). Fix and re-lint only the affected chapters (TTS is cached, so it takes seconds). At issues=0, open lint/<chapter>_sheet.jpg once.

6. Render, merge, verify, deliver

Run as many render chains in parallel as setup's "parallel renders" value, splitting the chapters between them:

cd ~/vidkit && nohup sh -c 'python3 vidkit.py render ch1.py; python3 vidkit.py render ch3.py; echo ALLDONE' > r1.log 2>&1 &
cd ~/vidkit && nohup sh -c 'python3 vidkit.py render ch2.py; echo ALLDONE' > r2.log 2>&1 &
python3 ~/vidkit/vidkit.py wait ~/vidkit/r1.log ALLDONE; python3 ~/vidkit/vidkit.py wait ~/vidkit/r2.log ALLDONE
cd ~/vidkit && python3 vidkit.py merge out/Final.mp4 out/ch1.mp4 out/ch2.mp4 out/ch3.mp4 && ffprobe -v error -show_entries stream=codec_type,duration -of csv=p=0 out/Final.mp4

Stream durations should agree within 0.1 s. Deliver the merged file with a one-line caption; if time is short, say which chapters to watch first.

Writing narration for TTS

  • One sentence per lines entry, 10 to 30 words. Put the sentence that introduces an item at that item's cue.
  • Spell acronyms with spaces ("E D A"), say formulas in words ("x bar", "n minus one"), write symbols out (≤ as "at most").
  • No relative dates ("tomorrow"): the video is watched later.
  • Re-read each claim against what its chart actually shows. In quiz exhibits, never highlight the answer.
  • Voice ids: language/gender prefix + lower-case name (bf_emma, am_adam); lang="en-gb" for British, "en-us" for American. Other languages need narration written in that language.

Other formats

  • Silent videos (social clips, loops): scenes with lines=[], hold (seconds) and cues (reveal times in seconds). Add music afterwards: ffmpeg -i v.mp4 -i music.mp3 -filter_complex "[1:a]volume=0.12[m];[0:a][m]amix=inputs=2:duration=first[a]" -map 0:v -map "[a]" -c:v copy out.mp4
  • Vertical 9:16: set vidkit.W, vidkit.H = 1080, 1920 and a custom BODY at the top of the spec, and use custom draws; the built-in kinds assume 16:9.
  • Screen recordings or real footage: this skill does not cover them; use a general video-editing workflow.

Verwandte Skills