Communitygithub.com

JustChenk/handdrawn-explainer-video

把任意主题制作成 3 分钟以内的手绘卡通风格科普教学短片(JS + Canvas 逐帧渲染成 1080p MP4,无配音)。当用户要求'做个教学视频/科普短片/手绘动画视频/讲解视频',或给出一个主题、文章链接希望生成讲解视频时使用。关键词:教学视频、科普视频、手绘动画、科普短片、Canvas 动画、讲解视频

handdrawn-explainer-video 是什么?

handdrawn-explainer-video is a Claude Code agent skill that 把任意主题制作成 3 分钟以内的手绘卡通风格科普教学短片(JS + Canvas 逐帧渲染成 1080p MP4,无配音)。当用户要求'做个教学视频/科普短片/手绘动画视频/讲解视频',或给出一个主题、文章链接希望生成讲解视频时使用。关键词:教学视频、科普视频、手绘动画、科普短片、Canvas 动画、讲解视频.

兼容平台✓Claude Code~Codex CLI~Cursor✓OpenCode
npx skills add JustChenk/handdrawn-explainer-video

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

HandDrawn Cartoon Educational Video Generator

Goal: Given a topic (optionally with a link/materials), produce a ≤3-minute, no-voice-over, hand-drawn cartoon style, junior-high-school-level accessible, hook-at-the-start 1080p educational short film MP4, along with supporting research materials and storyboard script.

Installation

This repository is a standard Agent Skill package (SKILL.md manifest + template/script/font and other resource files). Any AI programming assistant that supports the Agent Skill mechanism can load it. Installation method = place the repo into the tool's skill load directory. Below uses CodeBuddy as an example:

Option A · User-level installation (applies to all projects, recommended)

git clone https://github.com/JustChenk/handdrawn-explainer-video.git \
  ~/.codebuddy/skills/handdrawn-explainer-video

Option B · Project-level installation (applies only to the current project)

cd <your project root>
git clone https://github.com/JustChenk/handdrawn-explainer-video.git \
  .codebuddy/skills/handdrawn-explainer-video

The installation method is identical for other tools supporting the Agent Skill specification; just replace ~/.codebuddy/skills/ (or .codebuddy/skills/) in the commands above with the skill directory of your tool (e.g., ~/.claude/skills/, ~/.opencode/skills/, etc., refer to their documentation).

After installation, open a new session and the skill will be automatically discovered (Skill name: handdrawn-explainer-video). It triggers when the user says "make an educational video / popular science short / hand-drawn animation video" and provides a topic.

Runtime dependencies (install once before first use)

DependencyInstallationUsage
playwright-corePLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -g playwright-coreFrame-by-frame rendering (does not download browser)
Chromium / ChromeMust be available locally; otherwise set CHROME_PATH to the executableRendering engine (render.js auto-detects)
ffmpegapt install ffmpeg or install from official siteCompose frame sequence into MP4 (encoder auto fallback)
Node.js ≥ 18Install from official siteRun render.js

Output Directory Convention (Read First, Follow Throughout)

All output for each video is uniformly stored in a folder named after the topic under the project root, for example, when the topic is "Large Model Recognizing Characters":

<project root>/<topic folder>/          # e.g., D:/.../vibe视频制作/大模型认字/, topic name concise (≤10 chars)
├── research_materials.md               # Phase 0 output (refined draft, data points with research/ citation links)
├── research/                           # Phase 0 output (raw research traces, one md per source)
│   ├── 01-source_title.md
│   ├── 02-source_title.md
│   └── ...
├── storyboard.md                       # Phase 2 output
├── video.html                          # Animation project (interactive preview version)
├── scenes.js / framework.js / handdrawn.js
├── assets/fonts/*.ttf                  # Handwriting fonts (real copy or junction pointing to <skill>/assets)
├── testframes/                         # Phase 4 self-check frames (can be deleted after delivery)
├── frames/                             # Phase 5 full frames (bulky, can be deleted after encoding)
└── <video_title>.mp4                   # Phase 5 final video
  • Create this folder right at the start of the work; thereafter all research materials, research/, storyboard, project, frames, and final video are written inside it. Do not scatter files to the project root, tmp/, or other locations.
  • In all commands below, <topic folder> refers to this directory; <project root> is the current working directory.
  • frames/ and testframes/ are intermediate outputs; after delivery confirmation, remind the user they can be deleted (a 170s video's frames are about 1-2 GB).
  • research/ is a working trace for source verification; keep locally only, do not distribute with the project (excerpting the original text may have copyright risks). Bibliography for public repositories is maintained separately in README.

When to Use

  • User asks "make an educational/popular science/explainer video" or "make a hand-drawn animation video"
  • User provides a topic, article, or link and wants it turned into video content
  • User wants to "make an animated short with JS+Canvas"

Hard Requirements (Non-Negotiable)

#RequirementImplementation
1Duration ≤ 3 minutesTotal scene duration ≤180s, recommend 150-175s, within 8 scenes
2No audioNo voice-over, no music; all information conveyed through visuals and subtitles; focus all effort on visuals
3Junior-high accessibleBan jargon; must explain necessary terms immediately with analogies (e.g., "token = numbered puzzle piece"); ≤2 lines of large text per screen
4Hook at startThe first scene (within the first 15s) must create a cognitive conflict/suspense, see [Hook Formulas]
5Actively search when materials insufficientWhen user-provided materials are insufficient to support a 3-minute narrative, must WebSearch to supplement research, cross-verify facts
6Communicate if direction unclearWhen topic is vague/materials insufficient/multiple angles possible, first communicate with AskUserQuestion, offering 2-4 options

Workflow (6 Phases)

Phase 0 · Material Analysis and Research (Must be Thorough)

  1. Has link → WebFetch the full text, extract: core problem, key concepts, data points, examples, quotable quotes.

  2. Has files (user-uploaded or existing in project) → Read and parse.

  3. Materials insufficient to support 150s+ narrative → WebSearch 2-4 rounds:

    • Search authoritative sources (papers, official docs, frontline tech blogs) to verify key numbers;
    • Search for analogies and counterintuitive facts (both hooks and "aha moments" rely on them);
    • Key data must be traceable; if not found, write "illustrative/approx", never fabricate precise numbers.
  4. Raw research trace (leave a trace for every information source): For each source processed (fetched page / search result / user material), immediately create a md file under <topic folder>/research/, named number-source_title.md (e.g., 01-TokenizationOverview.md), with a uniform structure:

    # Source Title
    - URL: https://... (for local user materials, write file path)
    - Fetch time: YYYY-MM-DD
    - Type: Full fetch / Search result / User material
    
    ## Summary
    One paragraph summarizing the core content and credibility assessment of this source
    
    ## Key Original Excerpts
    > Key sentences, data, quotable quotes adopted by the video, retain original wording (short articles can be copied in full; long summaries only excerpt adopted parts)
    
    • Granularity adaptive: full text for short articles; for long summaries, save "summary + original excerpts of adopted parts" to avoid bloating research/;
    • If one WebSearch result yields multiple useful sources, they can be merged into one file, listing each URL and excerpt;
    • research/ is a local trace for source verification, do not distribute with the project.
  5. Write the researched materials into <topic folder>/research_materials.md (the folder has already been created per [Output Directory Convention]), structure: Core Problem / Key Concepts / Data Points and Examples / Quotable Quotes / Candidate Narrative Arcs. Data points and quotable quotes must have source citations at the end, format: (Source: [01-Overview](research/01-xxx.md)), one-to-one correspondence with research/ files, forming a three-layer traceability chain "final video → research materials → original sources".

Phase 1 · Direction Confirmation (When Needed, Don't Skip Judgment)

In any of the following situations, first communicate with AskUserQuestion (give 2-4 options per question, put the recommended option first):

  • Topic too broad, multiple possible angles → Options: different approaches (e.g., "principle popular science" vs "pitfall avoidance guide" vs "industry gossip")
  • Materials too thin, still insufficient after research → Options: supplement directions A/B/C, or shorten to 90s quick-cut version
  • Target audience/purpose unclear → Options: General public popular science / Workplace presentation / Student teaching

When the topic is clear and materials are sufficient, go directly to Phase 2 and before starting, confirm with the user in one paragraph the narrative arc (title + one sentence per scene), no excessive interruption.

Phase 2 · Storyboard Script

Write into <topic folder>/storyboard.md. The storyboard table has one row per scene: Timecode / Chapter / Visual Key Points / Subtitles & Quotable Quotes.

Narrative Skeleton (Within 8 scenes, total duration ≤180s):

SceneDurationPurposeContent
112-17sHookSee Hook Formulas below
220-28sProblem definitionExplain the core concept (use analogy, explain thoroughly in one go)
322-30sPrinciple demonstrationStep-by-step animation of core mechanism/process
4-620-24s eachExpansion2-3 parallel points (cost/examples/comparison/data)
715-18sExtensionTrends/future/what to do
810-12sClosureQuotable quote + echo the opening hook

Hook Formulas (Choose One of Four):

  • AI also makes mistakes: Show a scenario where "humans answer instantly, AI/common sense fails" (side-by-side quiz, error demonstration)
  • Counterintuitive assertion: "You think X, but actually Y", with a visually impactful image
  • Soul-searching question: Directly throw a question at the audience they can't answer
  • Astronomical number: A specifically absurd number ("a difference of 54.3 times")

Popularization Techniques: Prioritize analogies (puzzle, chopping vegetables, moving bricks, stamping); specify numbers (not "many" but "94%"); every concept must have a plain-language explanation on first appearance; use conversational short sentences in subtitles, avoid formal long sentences.

Phase 3 · Animation Production

Project Setup (execute inside <topic folder>, all outputs stay in this folder):

# <topic folder> = <project root>/<topic name>, already created in previous step
cd <topic folder>
cp <skill>/templates/handdrawn.js <skill>/templates/framework.js <skill>/templates/video.html .
cp <skill>/templates/scenes_example.js scenes.js   # As a starting point for rewriting
# Three handwriting fonts (required, to prevent tofu blocks), choose one of two methods:
#   Method A · Windows (recommended): junction, zero copy, only one copy on disk
#     cmd //c "mklink /J assets <skill>/assets"    # Git Bash syntax; PowerShell use New-Item -ItemType Junction
#   Method B · Any platform: direct copy (self-contained project, can be moved entirely)
#     cp -r <skill>/assets .

Then rewrite the scene functions in scenes.js (scenes_example.js is a complete reference implementation, includes helper functions like tile/dashLine/stamp). Only three things need to be changed:

  1. scenes.js: Rewrite scene1..sceneN (refer to the example scene patterns below)
  2. framework.js top: SCENES array – change the number of scenes and each scene's start/dur
  3. video.html: window.VIDEO_HEADER header text

Key Conventions (Violating them causes bugs):

  • Check the signature before calling any drawing function (see quick reference table below / handdrawn.js top signature table). These functions have many parameters, many with default values. Omitting or misplacing arguments does NOT throw a JS error, it just manifests as "text disappeared" or "a random number appeared on screen". This is the most common source of bugs in this library; you must run Phase 4's precheck.js after writing.
  • Scene functions receive global time t; all internal seg(t, a, b) time points must be consistent with SCENES' start/dur—do not treat the scene's start time as 0
  • All random effects are driven by seed parameter (ensuring reproducibility for same frame, no flickering in frame-by-frame recording); new elements appearing should use easeOutBack(seg(...)) bounce
  • Element drawing order: Background → Scene → wipe transition → progress bar (framework handles this already)
  • Fonts: ZCOOL KuaiLe (Chinese body text), Patrick Hand (English/numbers), Caveat (English titles); handText already has null color/font fallback internally
  • Composition safe zone: x∈[80,1840], y∈[70,1000] (bottom 1050 is progress bar); when one screen has too much information, it's better to split into two scenes than cram it in
  • For elements drawn in a local coordinate system with ctx.translate/scale (price tags, badges, text inside cards), the coordinates passed to handText must be [local coordinates] (e.g., 0,2 / 10,2), NOT page absolute coordinates; otherwise, text will run off the screen

API Signature Quick Reference (Error-Prone Items, complete table in handdrawn.js top comment):

FunctionSignatureCommon Mistake
handText(ctx, txt, x, y, size, o)Second parameter is text; x/y is text anchor, not content
priceTag*(ctx, x, y, txt, seed, o)Project custom; internally writes text with local coordinates
badge*(ctx, x, y, s, txt, seed, o)4th is scale s, 5th is text! Omitting s will render seed as a number
chapterTitle(ctx, txt, t, a, b, seed, sub)3rd is global time t; sub can be string or {sub:'..'}
banner(ctx, y, txt, t, a, b, seed, o)No x parameter! Passing an extra x will misalign all parameters
sticky(ctx, x, y, w, h, seed, o)Text goes through o.label, not positional parameter
tokenCard(ctx, x, y, w, h, o)Text goes through o.label / o.num / o.sub
jdot(ctx, x, y, r, color, alpha)color is a positional parameter, not o.color
drawMug*(ctx, x, y, s, seed, o)Text goes through o.label

Items marked with * are project custom helper functions (not in the library, need to write yourself). precheck.js will include them in its validation, so custom helpers should also follow the "text before numbers, numbers before seed" signature convention.

Writing Habits (Naturally Avoid Misalignment): Unify helper signatures as (ctx, x, y, [numeric params...], txt, seed, o={}), i.e., text always immediately after numeric parameters and before seed; after writing calls, immediately run precheck.js.

Visual Style Parameters (built into handdrawn.js, use directly):

  • Cream paper background #FBF4E6, ink color #3B3229; accent colors: Red #E4572E Yellow #F5B82E Blue #2E7DD1 Green #3E9B4F Purple #8A5FB0
  • Hand-drawn jitter: change seed 8 times per second (boiling lines); line drawing use jline/jcircle/jrr/strokePts series
  • Common components: chapterTitle (chapter sticker), bubble (speech bubble), sticky (sticky note), tokenCard/tile (card), drawArrow (hand-drawn arrow), drawCheck/drawCross (check/cross), circled (red circle annotation), drawHuman/drawRobot (characters), drawBurst (sparkles)

Scene Pattern Library (Just Apply):

  • Comparison Scene: Left-right split (human vs machine / Plan A vs B), with one character + card on each side below
  • Process Scene: Input → Hand-drawn machine/arrow → Output (token dropping, merging animation)
  • Data Scene: Hand-drawn bar chart growth animation + large number sticker card + mini-man moving bricks for visualization
  • Card Scene: 3 vertical cards in a row, popping in sequentially (parallel points/plan comparison)
  • Quotable Quote Scene: Centered large text + red drawn underline + small elements echoing the beginning

Phase 4 · Self-Check (Cannot Skip)

Step 1 (Required): Static Self-Check – Run before rendering, saves a full round of rework

cd <topic folder>
node <skill>/scripts/precheck.js scenes.js handdrawn.js framework.js
# Only proceed if exit code is 0; if ERROR is reported, fix it first, otherwise the error will
# manifest as "a random number on screen / some text disappeared" in the final video,
# easily mistaken for a design element

precheck.js checks four things (validates with actual function signature, not hardcoded):

  1. Parameter type misalignment: numeric position received a string (e.g., omitted badge's s, 'Seller' falls into scale position), text position received a number (seed is drawn as text) – this category is historically the most frequent bug
  2. Parameter count: fewer than the number of required parameters
  3. SCENES timeline continuity, all sceneN are defined, total duration ≤180s
  4. Time base: whether scene functions mistakenly use scene-relative time (that scene will be completely blank)

To debug a single function, use --dump to see parameter binding:

node <skill>/scripts/precheck.js scenes.js handdrawn.js framework.js --dump badge
# Prints every badge() call site, showing "parameter name <= actual value" for each parameter

Step 2: Render test frames and Read them individually

cd <topic folder>   # First time, install rendering dependencies: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i playwright-core
node <skill>/scripts/render.js ./video.html ./testframes --test "3,8,24,58,80,110,130,150,166"
# Test frames go to <topic folder>/testframes/, Read each frame to check

Read each test frame individually and check the following checklist:

  • No overlapping text, no text obscured, no text exceeding card/screen boundaries
  • No "unexplainable numbers/letters" on screen—any number whose meaning you cannot explain (e.g., a mysterious 304), treat as a bug, do not dismiss as a design element
  • Every element that should have text actually has text: check badges, price tags, cards, sticky notes one by one (text disappearing is also a symptom of misalignment, harder to detect than extra numbers)
  • No font tofu blocks (□) – if they appear, check if assets/fonts are in place, or substitute rare characters (e.g., Myanmar) with Chinese descriptions
  • Key time points in each scene have content (no unexpected blank frames)
  • Spelling errors, numbers match research materials
  • At scene transitions, visuals do not break continuity within 1s before/after

When discovering issues, fix the code, rerun precheck.js first, then re-render the corresponding time points for verification, until all pass.

Phase 5 · Full Rendering and Encoding

cd <topic folder>
# Full rendering (4080 frames ~ 3 minutes, recommend run_in_background):
node <skill>/scripts/render.js ./video.html ./frames --fps 24 --dur <total duration>
# Encoding (encoder auto fallback: libx264 → libopenh264 → libsvtav1), final video written in topic folder:
bash <skill>/scripts/encode.sh ./frames 24 "./<video_title>.mp4" 4.5M
# Frame sampling for review (output <topic folder>/check_%d.jpg):
ffmpeg -y -i "./<video_title>.mp4" -vf "select='eq(n\,200)+eq(n\,1500)+eq(n\,3900)'" -vsync vfr check_%d.jpg

Phase 6 · Delivery

Use present_files to sequentially provide: <topic folder>/<video_title>.mp4 → video.html (interactive preview version) → storyboard.md → research_materials.md → source js files. In the summary, write clearly: duration/resolution/one sentence per scene/production method/how to modify and reuse; and remind that frames/, testframes/ can be deleted to free up space.

Technical Notes (Pitfalls Already Encountered)

  1. Scene timeline: draw() passes global t; do not use t - scene.start inside a scene function.

  2. libx264 may not exist: encode.sh has a built-in fallback chain, use it directly.

  3. Fonts must be loadable locally: Google Fonts CDN may not load completely during headless browser frame-by-frame screenshots; use @font-face with local ttf + document.fonts.load() explicit wait. Font files can be copied into the topic folder (self-contained), or under Windows create an NTFS junction to <skill>/assets for zero-copy sharing (tested with file:// rendering; junction scheme makes the project dependent on the skill installation path existing; when sharing with others, restore to a real copy).

  4. Rounded rectangle path: The four corners of buildRoundRectPts must be continuous clockwise (already fixed in the library, do not revert to old writing), otherwise cards appear "flag-like".

  5. Non-Latin text rendering risk: Uncommon characters (Myanmar, rare symbols) will turn into tofu blocks in a lean Linux font environment; use Chinese label descriptions instead.

  6. Rendering performance: ~24 frames/second (1080p), 170s video ≈ 3 minutes rendering; use run_in_background for very long tasks.

  7. Parameter misalignment (most frequent bug in this library, understand the mechanism):Library functions have many parameters, many with default values, for example

    • handText(ctx, txt, x, y, size, o)
    • banner(ctx, y, txt, t, a, b, seed, o) ← No x
    • badge(ctx, x, y, s, txt, seed, o) ← 4th is scale s, 5th is text

    When calling intuitively, it's easy to "omit a middle parameter"; JS does NOT throw an error: each subsequent argument shifts forward, so ① Text that should appear falls into a numeric slot → text silently disappears (looks like "this element wasn't designed to have text"); ② A number that should be seed/size falls into a text slot → an extra number appears on screen (e.g., 304). Both symptoms are easily mistaken as design effects and overlooked, therefore:

    • Before writing a call site, check the signature table at the top of handdrawn.js and the SKILL's “API Signature Quick Reference”;
    • Immediately after writing, run node <skill>/scripts/precheck.js (validates argument count and position types, covers project custom helpers);
    • During self-check, any "number whose meaning cannot be explained" should be treated as a bug; use --dump <function_name> to see parameter binding;
    • Write custom helpers uniformly in order (ctx, x, y, [numeric params...], txt, seed, o={}), text always follows numeric params, always before seed.
  8. Local coordinates vs absolute coordinates: For elements drawn after ctx.translate/scale (price tags, badges, text inside cards), the coordinates passed to handText must be local coordinates (e.g., 0,2, 10,2). Mixing absolute coordinates will make text run off the screen or overlap other elements.

Acceptance Checklist (Go Through Each Item Before Delivery)

  • node <skill>/scripts/precheck.js scenes.js handdrawn.js framework.js exit code is 0 (no parameter misalignment/no timeline gaps/no empty scenes)
  • Test frames individually Read, every number on screen has a clear meaning, every element that should have text actually has text
  • Duration ≤ 180s, 24fps, 1920×1080, H.264, yuv420p, faststart
  • No audio tracks
  • Scene 1 has a clear hook within 15s
  • Every professional concept has an analogy explanation; spot-check a junior-high student can retell the gist
  • Key data matches research materials, no fabrication, and every data point can be traced back to the original source along the research/ citation chain
  • Ending has a quotable quote and echoes the beginning
  • research_materials.md + storyboard.md + interactive preview html delivered together
  • All outputs are within <project root>/<topic folder>/, project root has no scattered files

相关技能