Ink History Video (ink_history_video) v2
Generates the entire video programmatically, without using video editing software. Example from "The Legend of Baishatun Mazu's Pink Superfast" (2026-10).
Differences Between v2 and v1
- Engine and Scenes Separated:
engine.pyremains unchanged; to change the topic, only writescript.json+scenes.py. - Initial Version Without Writing Code: Scenes without custom scene code use generic scenes (
preset: landscape/river/sea/village/night, intro and outro auto-generated), allowing users to review the pacing first, then replace key scenes with custom ones. checkCommand: Runs all automatable rules fromlessons.md(missing characters, vertical text symbols, subtitle length, missing images, narration clipping, mixed models, output specs) in one pass.- Cross-platform: Automatically finds a Kai style font (BiauKai → TW-Kai → LXGW WenKai → AR PL UKai); works on Windows, macOS, and Linux.
- Fixes: Loudnorm is now applied to the final version as well (v1 only applied it to the draft); if the file exceeds the size limit, bitrate is automatically lowered and re-encoded; old segments are automatically cleaned up if the process is interrupted; missing images are replaced with light ink silhouettes without crashing; outro, seal text, and music mood are now configured in
script.jsoninstead of being hardcoded ass9or "Mazu". - Works Without API Keys:
tts.py --edge(free Taiwanese accent),--voxcpm(cloned teacher voice),--placeholder(espeak placeholder, for testing only).
Files
| File | Purpose |
|---|---|
scripts/engine.py | Engine: drawing components, scene base, generic scenes, title calligraphy, transitions, narration processing, background music, checking, output |
scripts/build.py | Command entry point: check / audio / stills / cover / draft / video / encode |
scripts/tts.py | Line-by-line Gemini TTS; automatically switches model when quota is exhausted, logs in tts/models.json; --list, --placeholder |
scripts/scenes_example.py | Baishatun example custom scenes (copy to scenes.py and modify) |
scripts/requirements.txt | numpy pillow scipy fonttools google-genai |
references/script_example.json | Narration script and storyboard format example (Baishatun, paired with scenes_example.py) |
references/script_preset_example.json | Example using only generic scenes (Red Cliff Night Cruise, no scenes.py needed) |
references/lessons.md | Rendering architecture and check rules (must read before starting) |
script.json Fields
| Field | Description |
|---|---|
title / subtitle | Film title, subtitle (intro) |
seal_text | Seal text (2 or 4 characters), shared between intro, title calligraphy, and outro |
ending_lines | Vertical text columns for outro (right to left); only needed when using the generic outro |
style / voice / tts_models | TTS tone description, voice (default Charon), model priority order |
output_dir / output_name / max_mb | Output path (relative to project folder), filename, size limit (default 20) |
font | Specify font path (optional, auto-detected) |
scenes[].id / tag / seal / lines | Scene ID, vertical calligraphy in top right, whether to stamp under the calligraphy, narration sentences |
scenes[].mood | Calm / Sad / Heavy / Marching / Climax / Solemn / Joyful / Outro, or a custom dict |
scenes[].preset | Used when no custom scene exists: landscape / river / sea / village / night; can add sun, boat, storm |
The last scene is automatically used as the outro (7.5 seconds duration).
Standard Workflow (Two 🛑 Stops – Must Wait for User)
1. Intake
Confirm: topic, whether to draft the narration script, voice (default Gemini TTS / Charon + tone description), visual focus, output location and size limit (default 20MB).
- API keys are only obtained in the conversation; passed via the environment variable
GEMINI_API_KEYwhen executing, never written into any file. - Create project folder
project/, install packagespip install -r scripts/requirements.txt. All commands are executed insideproject/; scripts can be used without copying:(On Windows, prependcd project && python <skill>/scripts/build.py checkset PYTHONIOENCODING=utf-8.)
2. Narration Script & Storyboard → 🛑 STOP 1
- First verify historical facts; for contested dates or numbers, annotate with "common account" and remind the user during confirmation.
- Output: film title, scene descriptions, vertical calligraphy in top right, whether to stamp, music mood, and full narration script.
- Present the storyboard in a table; wait for user confirmation before starting production. If the user changes the title, check whether the narration needs a corresponding line.
- After confirmation, write to
project/script.json, immediately runbuild.py check(this catches missing characters, vertical text symbols, and overly long subtitles at this step).
3. Line-by-line Narration Recording
GEMINI_API_KEY='<key>' python tts.py # Run in background; takes about 1 minute per line
python tts.py --list # First see which TTS models this key can use
python tts.py s3_1 # Rerun only a single line
- Place the user-specified model as the first priority in
tts_models. Free quota is about 10 uses per model per day; auto-switch to the next model on HTTP 429. - After completion, report which lines used which model from
tts/models.json(voice timbre may be inconsistent). - If no API key is available yet, use
python tts.py --placeholderto build the timeline and frames; later, runningtts.pywill automatically overwrite the placeholders. - Alternatives if the user has no API key (note which one was used in delivery):
python tts.py --edge: Microsoft Edge free Taiwanese accent voice (edge_voicedefault zh-TW-YunJheNeural, male), no API key required, but tone cannot be specified; requires internet access (some cloud environments may block it).python tts.py --voxcpm: Teacher's own cloned voice (VoxCPM2, reference filevoxcpm_ref), runs on a machine with voxcpm installed.- Apply for a Gemini API key: Google AI Studio → Get API key → Create API key, free.
4. Narration Processing, Timeline, Music
python build.py audio
- Remove head/tail pop noise, shorten overly long pauses, normalize volume and apply soft limiting; each scene's duration is set based on actual audio length; subtitles are split at pauses.
- Music is synthesized per scene's
mood, automatically lowered when narration is present; after mixing, apply two-stage loudnorm (-16 LUFS).
5. Visual Design & Frame Capture Checks
- First run with generic scenes:
python build.py stills, review pacing yourself (or let the user see). - Then write custom scenes for key moments in
scenes.py(referencescenes_example.py;from engine import *gives access to all components); any scene not listed inSCENEScontinues to use the generic scene. - If detailed images (people, statues, etc.) are needed, use the
openai_image_genskill to generate "ink-wash style, transparent background, only vermillion accents" images, place them inproject/assets/, and composite them withload_img()/put_img(). python build.py stills [scene_id...]captures frames (auto-skips transitions); self-check againstlessons.md, then runcheck.
6. Draft Output (Single-Pass Fast Compression)
python build.py draft && python build.py check
- Parallel rendering based on CPU core count, veryfast + CRF single-pass compression. Any subsequent re-renders during revision also use draft mode.
- When delivering, explain: specs, duration, file size,
checkresults, and that AI cannot hear the audio — the user must do a listening test.
7. Revisions
Revise based on user feedback, use python build.py stills <scene_id> for localized checks. When the user wants to confirm the cover frame, run python build.py cover (default: take the frame after the intro seal is stamped, before the first transition).
8. Final Version → 🛑 STOP 2
Only execute after the user explicitly says "final version / final draft":
python build.py video && python build.py check
- Two-stage compression: bitrate calculated based on duration; if size limit is exceeded, re-encode once with reduced bitrate. Use
encodeto only re-encode without re-rendering. - Verification:
checklists ffprobe specs and file size; also spot-check frames visually.
9. Post-Production (Only If the User Requests)
- Facebook post: apply
yijun_post_style, optionally include "This video was made by Claude". - YouTube upload: browser upload tools have a 10MB limit; the video must be dragged by the user into YouTube Studio; AI fills in other fields (title, description with chapter timestamps, thumbnail, tags, schedule); screenshot for user confirmation before publishing. "AI use" disclosure field is left to the user.
- Tutorial web page: apply
ijun_tool_intro_deploy, placed under/media/<slug>/.
Inviolable Rules
- Use only ink shades and a small amount of vermillion (fire, sun, plum blossoms, seals, incense embers).
- Do not write API keys into files; do not fabricate quotes or historical facts the user did not mention.
- Placeholder audio is for internal testing only — cannot be delivered as final product.
- Do not use two-stage compression for the draft version; only control file size in the final version.