Skip to content
Back to search

code-video-showcase

SkillWorks with Claude CodeGitHub

用纯代码(HTML/Canvas/SVG/Three.js 逐帧渲染 + Python numpy/scipy 合成配乐 + FFmpeg 合成)制作 30–90 秒卡点风格展示视频的完整技能。 适用于:复刻/仿制《Opus 5.5 视频风格展示》、DeepSeek V4.1-Flash 61s 风格样片、多风格切换卡点视频、纯代码视频、程序化视频、 HTML/Canvas/Three.js 视频、逐帧渲染 + 节拍同步、风格展示短片;要求不使用任何视频/图像/音乐生成模型。 包含:调用前置需求采集与主题选择、8 套主题配色 × 8 种材质、剪辑结构公式、11 种风格配方、大字卡系统、120BPM 配乐合成、Playwright 渲染管线、质检清单与可运行模板。 当用户提到「卡点视频」「风格展示视频」「纯代码做视频」「类似 Opus 5.5 / DeepSeek 风格展示」「逐帧渲染」「用代码做视频」 「HTML Canvas 视频」「程序化视频」「主题配色」「换配色」「配色主题」时必须触发。

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/moessif--code-video-showcase/badge.svg)](/listings/moessif--code-video-showcase)

HTML

<a href="/listings/moessif--code-video-showcase"><img src="/api/listings/moessif--code-video-showcase/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

The templates are a scaffold, not a finished film. From this repository:

# 0) intake first — collect the brief, lock the theme, write brief.json (references/intake.md)
#    pick a theme from assets/theme-previews/theme-contact-sheet.jpg (or re-render previews in step 3)

# 1) create a project and copy the templates into it
mkdir -p my-showcase/segments my-showcase/shared my-showcase/fonts my-showcase/audio my-showcase/out
cp templates/* my-showcase/
cp scripts/* my-showcase/
cp my-showcase/segment.html my-showcase/segments/01.html    # your first style segment
cp my-showcase/common.js my-showcase/themes.js my-showcase/segments/   # segment.html imports ./common.js and ./themes.js

# 2) install the renderer inside the project (theme previews need it too)
(cd my-showcase && npm i playwright)   # or playwright-core; the renderer accepts either

# 3) optional: render the eight theme previews + contact sheet (run from the repo root)
node scripts/theme-preview.mjs --root my-showcase

# 4) draft stills first (cheap) — t=0.2,0.8,1.4,2.0,2.6
cd my-showcase
node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --still 0.2,0.8,1.4,2.0,2.6 --outdir out/stills

# 5) render one 3 s segment; the renderer starts its own ephemeral static server
node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --out out/01.mp4 --duration 3

# 6) verify segment frame counts (h264 / yuv420p / 1920x1080 / fps / frames)
./qa-check.sh out 30

# 7) synthesize the soundtrack (8 s demo out of the box)
python3 synth_audio.py --out audio/demo.wav

# 8) concat + mux + 2-pass encode (defaults: duration 61, 30 fps, 3400 kbps, AAC 192k)
./concat-and-encode.sh segments.txt audio/mix.wav out/final.mp4

`segments.txt` is the concat demuxer list, one line per segment:

file 'out/00-opening.mp4'
file 'out/01-card.mp4'
file 'out/02-style-01.mp4'
...

Notes:

- `render-segment.mjs` embeds a small static server, so a local **path** is enough (`--page /segments/01.html`); a full URL is used verbatim. Style segments take `--t0 0.35 --speed 1.4` — for a relative page the renderer appends `?seg=1&t0=&speed=&dur=`, and `common.js` maps clip time `u` to scene time `t = t0 + u·speed`. - Rendering needs no separate server: the renderer embeds one. For manual browser previews only, serve the project root on port 4600 yourself — `references/render-pipeline.md` §3 documents an optional `tools/server.mjs` (`node tools/server.mjs --port 4600`) that is not shipped, because the renderer already contains an equivalent. To click through the theme boards interactively, serve the templates directory instead: `python3 -m http.server -d templates 4600`, then open `http://localhost:4600/theme-board.html?theme=aqua-morandi` (the boards import `./themes.js` as a module, so `file://` will not work). - The templates expect a local `shared/fonts.css` with `@font-face` rules for OFL fonts you download yourself. Fonts are not bundled. - Useful env vars: `CHROME_EXE` / `FFMPEG_EXE` for the renderer; `FFMPEG` / `FFPROBE` / `VIDEO_BITRATE` / `AUDIO_BITRATE` for the shell scripts (plus `PYTHON` for `qa-check.sh`). `node render-segment.mjs --help` lists every flag. - `synth_audio.py` is a toolkit plus a runnable 8 s demo; extend `build_arrangement()` to the full 61 s timeline using `references/audio-recipes.md`.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 385 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. ---
  2. name: code-video-showcase
  3. description: |
  4. 用纯代码(HTML/Canvas/SVG/Three.js 逐帧渲染 + Python numpy/scipy 合成配乐 + FFmpeg 合成)制作 30–90 秒卡点风格展示视频的完整技能。
  5. 适用于:复刻/仿制《Opus 5.5 视频风格展示》、DeepSeek V4.1-Flash 61s 风格样片、多风格切换卡点视频、纯代码视频、程序化视频、
  6. HTML/Canvas/Three.js 视频、逐帧渲染 + 节拍同步、风格展示短片;要求不使用任何视频/图像/音乐生成模型。
  7. 包含:调用前置需求采集与主题选择、8 套主题配色 × 8 种材质、剪辑结构公式、11 种风格配方、大字卡系统、120BPM 配乐合成、Playwright 渲染管线、质检清单与可运行模板。
  8. 当用户提到「卡点视频」「风格展示视频」「纯代码做视频」「类似 Opus 5.5 / DeepSeek 风格展示」「逐帧渲染」「用代码做视频」
  9. 「HTML Canvas 视频」「程序化视频」「主题配色」「换配色」「配色主题」时必须触发。
  10. license: MIT
  11. metadata:
  12. domain: video-production
  13. reference: Opus 5.5 / DeepSeek V4.1-Flash 61s style showcase
  14. compatibility: Node 20+ / Playwright Chromium / FFmpeg (libx264+AAC) / Python 3.10+ (numpy, scipy). Works on Windows and WSL/Linux. No external video, image or music generation models; fonts must be open-source and served locally.
  15. allowed-tools: Bash, Read, Write, Edit, Glob, Grep
  16. ---
  17. # 纯代码卡点视频导演技能
  18. > 目标:不调用任何视频/图像/音乐生成模型,用**代码**逐帧画出画面、用 **numpy/scipy** 合成配乐,最后 FFmpeg 合成 MP4。
  19. > 参考样片:61.0s / 1920×1080 / 30fps / 1830 帧 / 120 BPM / H.264+AAC,见 `assets/contact-1fps.jpg` 与 `references/reference-film-analysis.md`。
  20. ## 0. 适用与不适用
  21. **适用**
  22. - 30–90 秒内快速切换多种美术风格的「风格展示 / 能力展示 / 产品宣传」短片;
  23. - 强节拍(120 BPM)、大字卡 + 风格段交替、结尾升华的卡点结构;
  24. - 同一套内容需要不同品牌气质(8 套主题:珊瑚暗夜 / 橙光白 / 水蓝白·莫兰迪 / 琥珀黑金 / 蓝图纸 / 石墨信号 / 青瓷白 / 绯墨剧场);
  25. - 用户明确要求纯代码、可复现、逐帧确定性渲染(同一 t 必出同一帧)。
  26. **不适用**
  27. - 需要写实镜头、真人、复杂叙事的长视频;
  28. - 需要调用文生视频/文生图/文生音乐模型的场景(本技能明确禁止)。
  29. ---
  30. ## 1. 交付物与硬约束
  31. | 项目 | 默认值 |
  32. |---|---|
  33. | 画幅/帧率 | 1920×1080,30 fps |
  34. | 时长 | 61.0 s = 1830 帧(可按公式改) |
  35. | 音频 | 48 kHz 立体声 AAC 192 kbps |
  36. | 视频 | H.264 High,yuv420p,libx264,2-pass 约 3.4 Mbps(成片约 26 MB) |
  37. | 节拍 | 120 BPM:1 拍 = 0.5 s,1 小节 = 2 s |
  38. | 主题配色 | 8 选 1,默认 `coral-noir`(原版:珊瑚 `#d97757` + 深底 `#0e0e0d`);角色 token 与选择流程见 §5、`references/intake.md` |
  39. | 字体 | 全部 OFL:Noto Sans/Serif CJK SC、Ma Shan Zheng、Long Cang、ZCOOL KuaiLe、ZCOOL QingKe HuangYou、Press Start 2P、JetBrains Mono、Inter、Orbitron、Playfair Display |
  40. | 字幕 | 不要底部字幕;信息都做成画面内的胶囊/HUD/注释 |
  41. | 确定性 | 画面是 `t` 的纯函数,禁止 CSS transition/animation、rAF、Date.now、Math.random |
  42. **每个片段必须满足**(Playwright 渲染契约):
  43. ```js
  44. window.DURATION = 3.0; // 片段时长(秒)
  45. window.renderFrame = (t) => { /* 只依赖 t 和常量;禁止时间/随机副作用 */ };
  46. window.__ready = false; // 字体等资源就绪后置 true
  47. window.__bootError = null; // 初始化失败时写入错误字符串(渲染器立即报错)
  48. ```
  49. ---
  50. ## 2. 十阶段工作流
  51. 1. **需求采集 + 主题锁定**(先做,不要先写代码):先读 `references/intake.md`;默认按 61s / 横屏 1920×1080 / 11 段 / 珊瑚暗夜 / 120BPM 电子起一版,**最多 2 轮**收齐信息——必问 4 项(题材、渠道/画幅、品牌名 `{{BRAND}}`、结尾 CTA),时长/风格数 N/主题/配乐给默认或按用户主动提调整。把 8 套主题预览图发给用户选(`theme-three-up.jpg` → `theme-contact-sheet.jpg` → 单主题图),锁定主题 id 后把全部答案写成项目根 `brief.json`(模板见 intake.md),后续所有页面用 `?theme=<id>` 透传。主题未锁定前不渲染成片。
  52. 2. **写剪辑表**:用第 3 节公式算出每一段 `[start,end,type,style,t0,speed]`,先落成 JSON/Markdown 常量,后面所有脚本都读它。
  53. 3. **环境准备**:Node/Playwright/Chromium/FFmpeg/numpy+scipy/本地字体;参考 `references/render-pipeline.md` 的跨平台方案(WSL 下 Playwright CDN 慢时用 Chrome for Testing + `executablePath`)。
  54. 4. **工程骨架**:`common.js` + `themes.js`(与 HTML 同目录)、`templates/theme-board.html`(主题预览)、`templates/segment.html`、`templates/big-card.html`、`templates/render-segment.mjs`、`templates/concat-and-encode.sh`、`templates/synth_audio.py`(渲染器内置静态服务器,无需另写)。
  55. 5. **逐段实现(外循环 11 次)**:先写场景 → 渲染 5–6 张静帧拼接触表检查构图与字体 → 再整段渲染 → `ffprobe` 核帧数。
  56. 6. **开场**:逐字打字 + 代码列上滚 + 粒子爆炸 + 闪白,8 s。
  57. 7. **大字卡**:4 套版式轮换,2 拍/张;砸入、速度线、回声字、`STYLE 0X / 11`。
  58. 8. **八连闪 + 结尾**(可选):8×0.25 s 的微海报,接着 6 s 电影感收尾。
  59. 9. **配乐合成**:120 BPM、A 小调、与剪辑表共用同一组时间常数;生成 WAV 后先检查频谱图与卡点对齐,再做「高频克制」听感自检(§8)。
  60. 10. **合成与质检**:分段 mp4 → concat → 混音 → 2-pass → 抽帧接触表 + 频谱图 + 人工看片;输出 `成片 + 封面帧 + 参数说明`。
  61. **每段闭环(必须)**:
  62. ```
  63. 设计 -> 写 HTML -> 渲染静帧(t=0.2/0.8/1.4/2.0/2.6) -> 拼接触表检查 -> 整段渲染
  64. -> ffprobe 帧数 == duration*30 -> 记录到进度表 -> 下一段
  65. ```
  66. 不要一次写 11 段再统一渲染;先跑通 1 段样板再复制,错误成本最低。
  67. ---
  68. ## 3. 时间结构(通用公式)
  69. 设风格数 `N`,每轮 `R = 4s`(大字卡 1s = 2 拍,风格展示 3s = 6 拍):
  70. ```
  71. 0 ── opening (O=8s) ── 8 ── 11 轮 ×4s = 44s ── 52 ── 大字卡 "还有更多?" (1s) ── 53
  72. ── 八连闪 (2s,8×0.25s) ── 55 ── 结尾 (E=6s) ── 61
  73. ```
  74. - 总时长 = `O + N*R + 1 + 2 + E`(本片 8+44+1+2+6 = 61 s)。
  75. - 展示段第一帧就是「啪」的卡点:style 段 `t0` 通常是 0–0.9 之间的场景内偏移,用 `t = t0 + u*speed` 把 3 s 的片段加速到 6 拍内。
  76. - 帧数校验:每段 `round(duration*30)`,全片合计必须 `== 1830`。
  77. - 参考样片实测:镜头切点 60 个;每轮切点 = `8+4k`(大字卡)、`9+4k`(风格段),其中风格段开头 9.0/9.033/9.067/9.1 有连续微切(卡点冲击/故障效果)。
  78. **61s 参考剪辑表**(品牌词替换成 `{{BRAND}}` 即可复用;t0/speed 来自原任务书,也是样片验证过的值):
  79. | 轮 | 大字卡(行1 / 关键词+后缀 / 强调色) | 风格 | t0 | speed |
  80. |---|---|---|---|---|
  81. | 1 | 想做 / 科普视频? / #ffcf5c | 扁平插画科普 | 0.35 | 1.4 |
  82. | 2 | 想做 / 知识讲解? / #58c4dd | 数学动画 | 0.5 | 1.45 |
  83. | 3 | 想开 / 产品发布会? / #a58bff | 极简发布会 | 0 | 1.0 |
  84. | 4 | 想做 / 培训课件? / #e0674b | 手绘白板 | 0.3 | 1.4 |
  85. | 5 | 想做 / 炫酷预告片? / #ff2bd6 | 赛博故障 | 0.8 | 1.3 |
  86. | 6 | 想拍 / 国风短片? / #e0513a | 水墨国风 | 0.5 | 1.35 |
  87. | 7 | 想做 / 数据新闻? / #ff5a4a | 数据可视化 | 0.4 | 1.4 |
  88. | 8 | 想做 / 游戏视频? / #ffd84a | 8-bit 像素 | 0.9 | 1.25 |
  89. | 9 | 想录 / 编程教程? / #c792ea | 代码录屏 | 0.4 | 1.4 |
  90. | 10 | 想要 / 3D质感? / #ff8a5c | Three.js 三维 | 0.3 | 1.3 |
  91. | 11 | 想做 / 竖屏短视频? / #ff5f9e | 竖屏短视频 | 0.3 | 1.45 |
  92. ---
  93. ## 4. 画面契约与公共库
  94. `templates/common.js` 提供(直接复制进项目):
  95. - 缓动:`ease.outQuad/ease.outCubic/ease.outExpo/ease.outBack/ease.inOutCubic` 等;
  96. - 种子随机:`mulberry32(seed)`;禁止 `Math.random`;
  97. - value noise + fbm;
  98. - 片段模式:解析 `?seg=1&t0=&speed=&dur=`,映射 `t = t0 + u*speed`;
  99. - 标准角标:`drawCapsuleLabel`(左上胶囊)、`drawCountdown`(右下 3 秒倒计时)、`drawStamp`(品牌水印);
  100. - 卡点冲击(`u∈[0,0.4]`):
  101. - 白闪 `0.85→0`,0.12 s;
  102. - 整体缩放 `1.13→1`,0.32 s,`outCubic`;
  103. - 抖动 14 px 衰减,0.16 s;
  104. - 之后整段缓慢推镜 `1→1.05`。
  105. - 禁止每个 HTML 自己调用 `requestAnimationFrame`;渲染器负责每帧调用 `renderFrame(t)`。
  106. 2D 片段的推荐骨架:
  107. ```js
  108. const seg = createSegment(); // 读取 URL 参数 + DURATION
  109. window.DURATION = seg.duration;
  110. window.renderFrame = (u) => {
  111. const { t, fx } = seg.sample(u); // t = t0 + u*speed;fx = { scale, shakeX, shakeY, flash, push }
  112. ctx.setTransform(1,0,0,1,0,0);
  113. ctx.clearRect(0,0,W,H);
  114. ctx.save();
  115. applyImpact2D(ctx, fx); // 缩放/抖动/缓慢推镜
  116. drawScene(ctx, t, u); // 只依赖 t/u
  117. ctx.restore();
  118. drawFlash(ctx, fx.flash); // 白闪盖在最上层
  119. };
  120. ```
  121. Three.js 片段:`renderer` 必须 `{ preserveDrawingBuffer: true }`;启动参数
  122. `--use-angle=swiftshader --enable-webgl --ignore-gpu-blocklist --enable-unsafe-swiftshader`。
  123. 镜头动画写 `camera.position`,不要依赖 `Date.now`。
  124. ---
  125. ## 5. 主题系统(8 套配色 × 8 种材质)
  126. 主题不是换三个颜色,而是**角色色板 + 材质 + HUD 规格 + 点缀色**四层一起换。数据唯一来源 `templates/themes.js`,完整规范(材质画法、token 阈值、推荐矩阵、加主题步骤)见 `references/themes.md`。
  127. | # | id | 名称 | 明暗 | 主材质 | 一句话 |
  128. |---|---|---|---|---|---|
  129. | 01 | `coral-noir` | 珊瑚暗夜 | dark | 胶片颗粒 | 默认,原版逐值一致 |
  130. | 02 | `claude-light` | 橙光白 | light | 纸面柔光 | 暖纸 + 陶土橙,品牌/知识 |
  131. | 03 | `aqua-morandi` | 水蓝白 · 莫兰迪 | light | 液态玻璃 · 柔光 | 雾面水色 + 淡绿/淡粉,品牌/生活方式 |
  132. | 04 | `amber-noir` | 琥珀黑金 | dark | 金属烫金 | 近黑 + 旧金,高端/电影感 |
  133. | 05 | `blueprint-stone` | 蓝图纸 | light | 蓝图网格 | 石色纸 + 钴蓝,工程/数据 |
  134. | 06 | `graphite-signal` | 石墨信号 | dark | 哑光工业 | 石墨灰 + 安全橙,开发者/硬件 |
  135. | 07 | `celadon-paper` | 青瓷白 | light | 水墨晕染 | 单色青 + 宋体,东方/文化 |
  136. | 08 | `crimson-theater` | 绯墨剧场 | dark | 舞台聚光 | 近黑 + 绯红,时尚/艺术 |
  137. 默认 `coral-noir` 与旧版逐值一致:**不传 `theme` 时老项目行为完全不变**。模板按 URL 选主题,也接受中英文别名:
  138. ```text
  139. /segments/01.html?theme=aqua-morandi
  140. /segments/big-card.html?theme=水蓝白&layout=1 # 别名同样有效
  141. ```
  142. ```js
  143. // 页面里读取主题(big-card.html / segment.html 已内置)
  144. const theme = themeFromURL(location.search); // ?theme=xxx / ?t=xxx → 主题对象
  145. drawThemeBackground(ctx, theme, W, H, t); // 底色 + 材质 + 颗粒(确定性)
  146. const hud = chrome(theme); // 胶囊/倒计时/水印配色
  147. drawCapsuleLabel(ctx, seg.index, name, category, hud.capsule);
  148. const c = cardColors(theme, layout); // 大字卡 4 版式:{ field, bg, ink, sub, keyword, echo, grid, sheen }
  149. drawGlassPanel(ctx, theme, { x, y, w, h }); // 仅 glass 主题的信息面板
  150. ```
  151. **铁律**
  152. - 浅色主题的胶囊/倒计时/水印必须用 `chrome(theme)`(深墨实体胶囊 + 浅字);照搬原版半透明黑胶囊会在纸上变成脏补丁。
  153. - 每套主题(含浅色)都有 `cardDark`:大字卡 layout 2/3 仍是深色卡,整片才有明暗节奏。
  154. - 大字卡字体固定 Noto Sans SC 900(卡是节拍器);主题 `type` 的字体只用于片头/结尾/风格段。
  155. - 风格段主色按主题 `accents` 替换;青瓷白保持单色青,橙光白禁止渐变光球,水蓝白柔光/玻璃是主角但只做局部。
  156. - 用户只给品牌色时,用 `accentOverride` 改 4 个值并校验对比度,不要自创第 9 套主题(见 `references/themes.md` §9)。
  157. - 改完主题必须 `node scripts/theme-audit.mjs --strict` 全绿(当前 8 套全通过)。
  158. 调性与禁忌、按内容类型选主题的矩阵见 `references/themes.md`;预览图在 `assets/theme-previews/`(单主题 8 张 + 联系表 + 三拼对比)。
  159. ---
  160. ## 6. 大字卡系统(1 s / 2 拍)
  161. 4 套版式轮换(样片实测顺序:强调色底 → 米白底 → 黑底 → 黑底;也可按任务书 `i%4` 自定义):
  162. > 下表颜色是默认主题 `coral-noir` 的实际值;换主题后底/字/关键词来自 `cardColors(theme, layout)`,版式结构不变(见 §5)。
  163. | 版式 | 底 | 字 | 关键词 |
  164. |---|---|---|---|
  165. | A 强调色底 | 卡片的强调色 | 黑 | 黑色下划线 |
  166. | B 米白底 | `#f4efe6` | 黑 | 强调色下划线,文字遮罩上推 |
  167. | C 黑底 | `#0e0e0d` | 白 | 强调色字 |
  168. | D 黑底 | `#0e0e0d` | 白 | 强调色字(换排版/位置) |
  169. - 第 1 拍 `t=0`:第一行 150 px 砸入;第 2 拍 `t=0.5`:关键词+后缀 280 px(Noto Sans Black)砸入。150/280 是任务书理论值;样片实测偏海报比例(约 70/170 px),模板用 76/190 px 并按宽度自动缩放,以「最多 8 个汉字放得下」为准,详见 `references/big-card-and-typography.md` 第 4 节。
  170. - **砸入**:缩放 `1.7→1`、模糊 `16→0`,时长 0.11 s,`outExpo`;伴随强调色速度线 + 径向光晕 + 画面抖动 6 px / 12 px。
  171. - 背景:600 px 描边回声大字横向漂移;右下角 `STYLE 0X / 11`;样片还有细线网格/流线背景。
  172. - 卡片期间配乐 drop-out(音乐压到 6%),只保留 2 拍打击;卡片结束接风格段「啪」。
  173. - 细节与观测偏差见 `references/big-card-and-typography.md`。
  174. ---
  175. ## 7. 风格展示配方(每段 3 s / 6 拍)
  176. 11 种风格是「视觉美术 + 技术实现 + 音色」三件套,完整参数见 **`references/style-recipes.md`**。
  177. 速查:
  178. | # | 风格 | 核心手法 | 关键元素 | 专属音色 |
  179. |---|---|---|---|---|
  180. | 01 | 扁平插画科普 | Canvas 2D 分层圆/三角/虚线轨道 | 太阳、地球、光束、标签胶囊 | 马林巴 |
  181. | 02 | 数学动画 | Canvas + 傅里叶(DFT 本轮) | 金色心形、KaTeX 公式、N/θ | FM 电钢琶音 + 铺底 |
  182. | 03 | 极简发布会 | Canvas 大字 + Three.js LatheGeometry | 金属戒指、LED 环、Nova Ring | 逐拍重低音 + 钟声 |
  183. | 04 | 手绘白板 | SVG stroke-dashoffset + turbulence | 灯泡→代码→视频、红圈 | 尤克里里 + 笔摩擦 |
  184. | 05 | 赛博故障 | Canvas 渐变/透视网格 + RGB 分离 | 条纹落日、城市、故障切片 | 失真锯齿 16 分 + 四拍底鼓 |
  185. | 06 | 水墨国风 | Canvas fbm 山峦 + 宣纸纹理 | 三远山、红日、渔舟、竖排书法 | 古筝五声 + 太鼓 + 笛 |
  186. | 07 | 数据可视化 | Canvas 条形赛跑 + CSS3D 透视 | 条图、年份、玻璃卡 | 方波琶音 + 滴答 |
  187. | 08 | 8-bit 像素 | 240×135 低分辨率 + pixelated | 机器人、金币、史莱姆、HUD | 芯片音乐 + 跳跃/金币 |
  188. | 09 | 代码录屏 | Canvas 编辑器 + 逐字代码 | 文件树、行号、实时预览 | lo-fi 电钢 + 黑胶噪声 |
  189. | 10 | Three.js 三维 | Lathe/TorusKnot + PhysicalMaterial | 粘土影棚、玻璃球、金属球 | 钟声琶音 + 弹跳 |
  190. | 11 | 竖屏短视频 | Canvas 手机壳 + 弹出动画 | 9:16、步骤卡、评论/点赞 | 808 + 超级锯齿 + trap 镲 |
  191. **每段必须有的视觉锚点**:左上胶囊标签(主题化编号,默认主题为珊瑚 + 风格名)、右下 3 秒倒计时/帧计数、1–2 个风格内小标签、标题或主视觉在 6 拍内完成一次完整叙事。不要底部字幕。
  192. ---
  193. ## 8. 配乐合成(120 BPM,A 小调,纯 numpy/scipy)
  194. - 音色:kick(正弦扫频)、snare、clap、hat、crash、sub boom、噪声 riser、反向镲、whoosh、拨弦、FM 电钢、FM 钟声、超级锯齿、808、方波/三角波、笛子;
  195. - 和弦(每段前 4 拍 / 后 2 拍):Am/F、C/G、F/G、C/F、Am/G、Am/Em、Dm/E、C/G、Dm/G、F/G、Am/F;
  196. - 结构:开场铺底 + 逐字键盘咔哒 → 4.55 s sub boom + 底鼓渐强 → 5.5 s 8 分踩镲 → 6.5–7.95 s 军鼓滚奏 → 7.45 s 反向镲;
  197. - 大字卡:第 1 拍 kick+tom,第 2 拍 kick+clap+sub+whoosh,后半反向镲;音乐压到 6%;
  198. - 风格段:6 拍律动 + 专属乐器;第一帧 kick+clap+snare+crash+sub+高频爆裂;
  199. - 混音:kick 包络侧链(闪避 55%)、2.2 s 合成混响、tanh 软削波、归一化 -0.6 dBFS;
  200. - **高频克制(必读)**:金属感音色(FM 钟声、拨弦、亮 saw stab、coin 音、高八度琶音)只作关键节点点缀,**全片 2–3 处**(标题揭示 / 结尾 impact / 唯一一次 resolve);统计与数字段用 sub+tom+kick+clap 的鼓点,不用铃音代替鼓点,更不要整段高音琶音铺底;
  201. - **高频自检**:切掉 <200 Hz 只听高频,若只剩「叮叮叮」= 点缀过量;8–16 kHz 在非点缀段应比关键点缀段低 ≥ 6 dB。细则与检测代码见 `references/audio-recipes.md` 第 7 节;
  202. - **实测参考**:样片 120.0 BPM、相位 0.0 s、86.3% 强 onset 落在 120 BPM 网格 ±30 ms 内;8/12/16… s 的大字卡起拍能量是前 300 ms 的 8–9 倍,9/13/17… s 的风格段起拍是 2.8–3.5 倍。
  203. 公式、编排表与混音函数见 **`references/audio-recipes.md`**,可运行骨架见 `templates/synth_audio.py`(模板默认输出 8 s demo,按编排表扩展到 61 s)。
  204. ---
  205. ## 9. 渲染管线
  206. 1. 本地静态服务器:`render-segment.mjs` 内置同源服务器(服务 `--root` 目录,默认 cwd);字体/KaTeX/Three 全部同源,禁止 `file://`。
  207. 2. `render-segment.mjs`:把 `--t0/--speed/--duration` 拼成 `?seg=1&t0=&speed=&dur=` 附加到相对路径页面 URL → 启动无头 Chromium → `goto(url)` → 等 `document.fonts.ready` 与 `window.__ready`(或 `window.__bootError`)→ 逐帧
  208. `page.evaluate(t => renderFrame(t), i/fps)` → CDP `Page.captureScreenshot({format:'jpeg', quality:95})` → stdin 管道给
  209. `ffmpeg -f image2pipe -framerate 30 -i pipe:0 -c:v libx264 -preset medium -crf 16 -pix_fmt yuv420p`。
  210. 3. `concat-and-encode.sh`:segment mp4 → concat(`-f concat -safe 0 -c copy`)→ 与音轨合成 → 2-pass 3.4 Mbps。
  211. 4. 每段渲染后 `ffprobe -count_frames` 校验帧数;全片合计 1830。
  212. **跨平台要点**(WSL 实测)
  213. - Playwright 自带浏览器下载可能极慢(本机 ~17 KB/s)→ 用 Chrome for Testing + `executablePath`;
  214. - WSL 跑 Chromium 需补齐 `libnss3/libnspr4/libasound2`,可用 `apt-get download` + `dpkg-deb -x` 解到 `~/.local/opt/chromium-libs` 并设置 `LD_LIBRARY_PATH`,无需 root;
  215. - 项目在 `/mnt/e` 时小文件写入很慢(2000 个文件约 4.9 s),venv/浏览器缓存放 Linux home;渲染帧直接管道,不落盘。
  216. 详见 **`references/render-pipeline.md`**;可运行模板在 `templates/`。
  217. ---
  218. ## 10. 质检清单(必须全绿)
  219. **画面**
  220. - [ ] 浏览器 console 无错误、无 404(favicon 也要处理);
  221. - [ ] 所有字体 `document.fonts.check()` 为 true,CJK 不缺字;
  222. - [ ] 每个风格段抽 5–6 帧拼接触表检查构图;全片抽 1 fps 接触表;
  223. - [ ] 无 CSS 动画/rAF/Date.now/Math.random(grep 检查);
  224. - [ ] 不用逐帧 `ctx.filter blur` / 大量 shadowBlur(模糊层预渲染再交叉淡化);
  225. - [ ] 镜头 transform 下不依赖 `getBoundingClientRect`(先缓存坐标);
  226. - [ ] 1920×1080 @1x,`preserveDrawingBuffer: true`,WebGL 用 SwiftShader。
  227. **主题**
  228. - [ ] `node scripts/theme-audit.mjs --strict` 全绿;
  229. - [ ] 浅色主题(02/03/05/07)的胶囊/倒计时/水印是深墨实体,不是半透明黑;
  230. - [ ] 大字卡 4 版式在所选主题下明暗交替成立(layout 2/3 仍是深卡);
  231. - [ ] 水蓝白:玻璃面板可见、淡绿/淡粉只从柔光与高光里透出、无脏灰;
  232. - [ ] 青瓷白画面里没有第二个彩色;蓝图纸/石墨没有柔光或投影;橙光白没有渐变光球;
  233. - [ ] 默认主题「不传 theme」与旧版逐像素一致(与基线做 PSNR/像素差对比);
  234. - [ ] 风格段没有被主题压成同一色,各段识别度仍在。
  235. **音频**
  236. - [ ] 频谱图检查每个卡点:鼓点与剪辑表时间误差 < 30 ms;
  237. - [ ] 大字卡有 drop-out,风格段第一帧有「啪」;
  238. - [ ] 结尾 5.5–6.0 s 淡出;峰值 -0.6 dBFS 不削波(tanh 后归一化);
  239. - [ ] 高频铃音点缀 ≤ 3 处且只落在关键节点;统计/数字段是低频鼓点,不是「叮叮叮」(`references/audio-recipes.md` §7);
  240. - [ ] 8–16 kHz 非点缀段比关键点缀段低 ≥ 6 dB;频谱图无连续亮高频竖条或水平泛音线;
  241. - [ ] 切掉低频(<200 Hz)听一遍:不应只剩「叮叮叮」;铃音之间留白 ≥ 1 拍。
  242. **合成**
  243. - [ ] 每段帧数 = duration×30,全片 1830 帧;
  244. - [ ] 音轨与视频对齐(`-shortest`,必要时 `-t 61`);
  245. - [ ] 2-pass 3.4 Mbps,H.264 yuv420p + AAC 48 kHz,体积约 26 MB;
  246. - [ ] 抽 6 帧出封面图;写一页参数说明(帧率/时长/风格数/字体/工具链)。
  247. ---
  248. ## 11. 文件地图
  249. ```
  250. code-video-showcase/
  251. ├─ SKILL.md ← 本文件(工作流/约束/索引)
  252. ├─ README.md ← 仓库首页:安装、快速上手、完整清单
  253. ├─ LICENSE ← MIT 许可证
  254. ├─ .gitignore / .gitattributes ← 忽略构建产物 / 强制 LF 行尾
  255. ├─ references/
  256. │ ├─ original-brief.txt ← 参考样片的原始任务书(可直接改品牌复用)
  257. │ ├─ reference-film-analysis.md ← 61s 样片的实测拆解(切点/画面/音频/偏差)
  258. │ ├─ intake.md ← 调用前置:8 项需求采集、BRIEF.json、主题推荐与锁定
  259. │ ├─ themes.md ← 8 套主题的调性/材质/token/HUD/推荐矩阵/加主题
  260. │ ├─ style-recipes.md ← 11 种风格的美术+技术+音色配方(含主题换色规则)
  261. │ ├─ big-card-and-typography.md ← 大字卡 4 版式、字体/字号/砸入参数
  262. │ ├─ audio-recipes.md ← 120BPM 编曲、音色合成公式、混音链
  263. │ └─ render-pipeline.md ← Playwright/FFmpeg/跨平台环境与命令
  264. ├─ templates/
  265. │ ├─ common.js ← 缓动/种子随机/noise/片段模式/卡点冲击
  266. │ ├─ themes.js ← 8 套主题数据 + 材质/卡片/HUD API(唯一数据源)
  267. │ ├─ theme-board.html ← 单主题预览板(?theme=<id>,1920×1080)
  268. │ ├─ segment.html ← 风格段 HTML 骨架(Canvas + Three 可扩展)
  269. │ ├─ big-card.html ← 大字卡骨架(4 版式 + 砸入 + 回声字)
  270. │ ├─ render-segment.mjs ← 逐帧渲染 → ffmpeg 管道(内置静态服务器)
  271. │ ├─ concat-and-encode.sh ← concat + 混音 + 2-pass
  272. │ └─ synth_audio.py ← numpy/scipy 音色库 + 编排骨架
  273. ├─ scripts/
  274. │ ├─ analyze-reference.sh ← 任意参考片 → 接触表/切点/频谱/音频分析
  275. │ ├─ theme-preview.mjs ← 批量渲染 8 套主题预览板 + 联系表 + 三拼对比
  276. │ ├─ theme-audit.mjs ← 主题对比度审计(--strict 可进 CI)
  277. │ └─ qa-check.sh ← 分段 MP4 质检(编码/尺寸/帧数)
  278. └─ assets/ ← 样片接触表、频谱、切点、配色数据、模板截图
  279. └─ theme-previews/ ← 交付用主题预览图(01–08、联系表、三拼)
  280. ```
  281. ### 模板实测记录
  282. `templates/segment.html` 与 `templates/big-card.html` 已用 `templates/render-segment.mjs` 实际渲染出 1920×1080@30fps 片段;`templates/synth_audio.py` 输出 48 kHz 立体声 WAV(峰值 -0.6 dBFS);`scripts/qa-check.sh`、`scripts/analyze-reference.sh`、`templates/concat-and-encode.sh`(concat + 2-pass + AAC)均实跑通过。
  283. 截图证据:`assets/template-demo-segment.jpg`、`assets/template-demo-card.jpg`。
  284. ---
  285. ## 12. 参考样片拆解摘要(实测)
  286. - 成片:61.013 s(视频 61.000 / 1830 帧)、1920×1080、30 fps、H.264 + AAC 48 kHz stereo、26.9 MB、~3.53 Mbps 总码率(视频流 3.32 Mbps + 音频 197 kbps);样片把品牌换成了 `DeepSeek V4.1-Flash`,其余结构/技巧与任务书一致。
  287. - 镜头:60 个切点;开场 0–8 s 打字 6 行;8–52 s 每 4 s 一轮(1 s 卡 + 3 s 风格);53–55 s 八连闪;55–61 s 结尾。
  288. - 画面锚点:左上胶囊「01 扁平插画 · 科普」、右下 3 秒倒计时、卡片右下 `STYLE 0X / 11`、风格内 HUD/小标签、结尾上下 138 px 黑边。
  289. - 大字卡:样片采用「强调色底 → 米白底 → 黑底 → 黑底」4 循环(不是任务书的 i%4 顺序),文字左中/居中排版两种。
  290. - 音频:120.0 BPM、相位 0 s、86.3% 强 onset 在 ±30 ms 内;开头 0–0.56 s 与结尾 60.38–61.0 s 为近静音。
  291. - 详细逐段观察与偏差见 `references/reference-film-analysis.md`,图片证据在 `assets/`。
  292. ---
  293. ## 13. 快速启动
  294. ```bash
  295. # 0) 先按 references/intake.md 采集 8 项信息,用 theme-three-up.jpg 锁定主题 → BRIEF.json
  296. # 再复制模板到新项目(common.js / themes.js 与 HTML 放同一目录,如 segments/)
  297. cp -r templates/* <project>/
  298. # 1) 渲染一个片段(渲染器自带同源静态服务器,无需另起服务);?theme= 选主题
  299. node render-segment.mjs --page "/segments/01.html?theme=aqua-morandi" --out out/01.mp4 --duration 3
  300. # 按剪辑表给风格段传场景偏移/速度(自动拼成 ?seg=1&t0=&speed=&dur=):
  301. node render-segment.mjs --page "/segments/01.html?theme=coral-noir" --out out/09.mp4 --duration 3 --t0 0.35 --speed 1.4
  302. # 2) 先出静帧接触表(不编码)
  303. node render-segment.mjs --page "/segments/01.html?theme=claude-light" --still 0.2,0.8,1.4,2.0,2.6 --outdir out/stills
  304. # 3) 生成/更新 8 套主题预览图(需 <project> 内已装 playwright;也可直接用仓库 assets/theme-previews/)
  305. node scripts/theme-preview.mjs --root <project>
  306. # 4) 合成
  307. ./concat-and-encode.sh segments.txt audio.wav out/final.mp4
  308. ```
  309. **写任务书时直接复制 `references/original-brief.txt`,替换品牌词、风格清单与文案即可**;主题按 `references/intake.md` 锁定,结构公式、技术管线、QA 无需改。
README.md · README · 534 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # code-video-showcase
  2. **A pure-code, beat-synced showcase-video skill — every frame drawn with HTML/Canvas/SVG/Three.js, every sound synthesized with Python, assembled by FFmpeg. No video, image or music generation models.**
  3. An Agent Skill for producing 30–90 s "style showcase" films: an 8 s opening, eleven style segments with 1 s big cards between them, an eight-flash montage, and a cinematic ending — all reproducible frame by frame.
  4. > **中文简介**:这是一个「用代码做视频」的 Agent Skill:画面用 HTML/Canvas/SVG/Three.js 逐帧渲染,配乐用 Python(numpy/scipy)合成,最后由 FFmpeg 合成 30–90 秒的卡点风格展示片,全程不调用任何视频、图像或音乐生成模型。仓库里包含剪辑结构公式、11 种风格配方、大字卡系统、120 BPM 配乐方案、Playwright 渲染管线、质检清单和可运行模板。完整中文说明见 [中文](#中文)。
  5. > **一键安装 / Install in one sentence**
  6. >
  7. > 把这句话发给你的 Agent:「把这个仓库安装成 Agent Skill:`git clone https://github.com/Moessif/code-video-showcase.git ~/.dsh/skills/code-video-showcase`(Claude Code 换成 `~/.claude/skills/`,通用 Agent 用 `.agents/skills/`),装好后读一遍 `SKILL.md` 确认可用。」
  8. >
  9. > Send this to your agent: "Install https://github.com/Moessif/code-video-showcase as an Agent Skill: clone it into `~/.dsh/skills/code-video-showcase` (`~/.claude/skills/` for Claude Code, `.agents/skills/` for generic agents), then read `SKILL.md` to confirm it works."
  10. [![MIT License](https://img.shields.io/badge/license-MIT-d97757?style=flat-square)](LICENSE)
  11. [![Node 20+](https://img.shields.io/badge/node-%E2%89%A5%2020-3c873a?style=flat-square)](https://nodejs.org/)
  12. [![FFmpeg](https://img.shields.io/badge/ffmpeg-libx264%20%2B%20AAC-007808?style=flat-square)](https://ffmpeg.org/)
  13. [![No generative models](https://img.shields.io/badge/generative%20models-none-d97757?style=flat-square)](#design-constraints)
  14. [![Latest release](https://img.shields.io/github/v/release/Moessif/code-video-showcase?style=flat-square&color=d97757)](https://github.com/Moessif/code-video-showcase/releases)
  15. **Changelog / 更新历史**:[CHANGELOG.md](CHANGELOG.md) · [GitHub Releases](https://github.com/Moessif/code-video-showcase/releases)
  16. > **Credits / 致谢**:This skill started from a prompt by the creator **Mixx.ftr** — this repository is an independent engineering reconstruction and extension of that prompt into runnable templates, themes and a deterministic render pipeline.
  17. >
  18. > 本技能最初起源于创作者 **Mixx.ftr** 的提示词,仓库是在其基础上做的工程化整理与扩展(模板、主题系统、预览与渲染管线)。
  19. ## Preview
  20. > **There is no finished demo video in this repository**, and the reference sample file is not distributed. The previews are analysis artifacts of the 61 s reference showcase the skill was reverse-engineered from, plus a placeholder still rendered from the shipped big-card template.
  21. ![1 fps contact sheet of the 61 s reference showcase](assets/contact-1fps.jpg)
  22. *1 fps contact sheet (8×8 tiles) of the reference film: the typing opening, eleven big-card / style-segment rounds, the eight-flash montage and the ending. Generated by `scripts/analyze-reference.sh`.*
  23. ![Eleven style segments of the reference](assets/style-tiles.jpg)
  24. *One representative frame from each of the eleven style segments: flat-science, Fourier math, product launch, whiteboard, cyber glitch, ink-wash, data race, 8-bit, code screencast, Three.js clay, vertical short.*
  25. ![Twelve big cards of the reference](assets/card-tiles.jpg)
  26. *All twelve big cards — eleven "what do you want to make?" prompts plus the "还有更多?" card — across four alternating layouts: accent-colour, paper, dark centred, dark left-aligned.*
  27. ![Spectrogram of the reference soundtrack](assets/audio-spectrogram.png)
  28. *Log-frequency spectrogram of the reference soundtrack: sparse intro (0–8 s), full-band groove from 8 s, visible 4 s structural seams, near-silent tail from 60.4 s.*
  29. ![Placeholder still rendered from templates/big-card.html](assets/template-demo-card.jpg)
  30. *`templates/big-card.html` rendered through `templates/render-segment.mjs` at 1920×1080: dark layout, "想开 / 产品发布会?" card, `STYLE 03 / 11`. Placeholder content — replace the copy, keep the timing.*
  31. Theme previews are in [Themes](#themes): `assets/theme-previews/theme-three-up.jpg`, `theme-contact-sheet.jpg`, and per-theme stills `01-coral-noir.jpg` – `08-crimson-theater.jpg` (generated by `scripts/theme-preview.mjs`).
  32. ## What it is
  33. The skill is a production recipe, not a model. It packages the structure measured off a real 61 s showcase: a timeline formula, a big-card system, eight theme palettes, eleven art-direction/technical/sound recipes, a 120 BPM synthesized score, a deterministic Playwright → FFmpeg pipeline, a QA checklist and runnable templates — full style palettes and six-beat animation maps live in `references/style-recipes.md`. Because every frame is a pure function of `t`, renders are deterministic: the same second always produces the same frame, on any machine.
  34. ### At a glance
  35. | Property | Default target | Notes |
  36. |---|---|---|
  37. | Format | 1920×1080, 30 fps, 1× device scale | one HTML page per segment |
  38. | Length | 61.0 s = 1830 frames | generalized by the formula below |
  39. | Video | H.264 High, `yuv420p`, libx264, 2-pass ≈ 3.4 Mbps | final file ≈ 26 MB |
  40. | Audio | 48 kHz stereo AAC 192 kbps | synthesized, no samples |
  41. | Tempo | 120 BPM — 0.5 s per beat, 2 s per bar | 1 s card = 2 beats, 3 s style segment = 6 beats |
  42. | Theme | 8 palettes, default `coral-noir` | omitting `?theme=` keeps the original coral `#d97757` on `#0e0e0d` visuals; see [Themes](#themes) |
  43. | Type | OFL fonts only, served locally | Noto Sans/Serif CJK SC, Inter, JetBrains Mono, Orbitron, Playfair Display, Ma Shan Zheng, Long Cang, ZCOOL KuaiLe, ZCOOL QingKe HuangYou, Press Start 2P |
  44. | Determinism | frame = f(t) | no CSS animation, rAF, `Date.now`, `Math.random`; no burned-in subtitles |
  45. Measured on the reference sample: container 61.013 s / video 61.000 s, 1830 frames, 60 scene cuts, H.264 ≈ 3.53 Mbps, AAC 48 kHz stereo ≈ 196.8 kbps, 26.9 MB. Source data in `assets/scene-cuts.txt` and `assets/audio-analysis.json`.
  46. ### The timeline formula
  47. ```text
  48. 0 ── opening (O = 8 s) ── 8 ── N × 4 s rounds = 44 s ── 52 ── "还有更多?" card 1 s ── 53
  49. ── eight flashes 2 s (8 × 0.25 s) ── 55 ── ending (E = 6 s) ── 61
  50. total = O + N·R + 1 + 2 + E # 8 + 11×4 + 1 + 2 + 6 = 61 s
  51. ```
  52. Each round `R = 4 s` = one big card (1 s / 2 beats) + one style segment (3 s / 6 beats). The first frame of every style segment is the beat hit. Frame check: each segment is `round(duration × 30)` frames and the whole film must total **1830**.
  53. ### The 10-stage workflow
  54. 1. **Lock the brief** — topic, brand placeholder `{{BRAND}}`, duration, number of styles `N`, one line per style, ending CTA.
  55. 2. **Write the edit table** — every segment as `[start, end, type, style, t0, speed]` in one JSON/Markdown constant file; all later scripts read it.
  56. 3. **Prepare the environment** — Node, Playwright/Chromium, FFmpeg, numpy + scipy, local fonts; see `references/render-pipeline.md` for the cross-platform setup.
  57. 4. **Scaffold the project** — static server, `common.js`, segment / card / render / concat / audio templates.
  58. 5. **Implement segments one at a time** (an 11-segment outer loop): scene → 5–6 stills → contact sheet → full render → `ffprobe` frame count.
  59. 6. **Opening (8 s)** — character-by-character typing, three scrolling code columns, particle burst, white flash.
  60. 7. **Big cards** — four layouts rotating, 2 beats each: slam-in, speed lines, echo type, `STYLE 0X / 11`.
  61. 8. **Eight flashes + ending (optional)** — eight 0.25 s micro-posters, then a 6 s cinematic ending.
  62. 9. **Score the film** — 120 BPM, A minor, sharing the exact timing constants of the edit table; verify against a spectrogram.
  63. 10. **Assemble and QA** — segment MP4s → concat → mux → 2-pass encode → contact sheets + spectrogram + human review.
  64. The mandatory inner loop for every segment:
  65. ```text
  66. design -> write HTML -> stills at t=0.2/0.8/1.4/2.0/2.6 -> contact sheet
  67. -> full render -> ffprobe frames == duration*30 -> log -> next segment
  68. ```
  69. Do not write all eleven segments and then render once; get one segment perfect and copy it.
  70. ### Big-card system (1 s / 2 beats)
  71. | Layout | Background | First line | Keyword | Underline |
  72. |---|---|---|---|---|
  73. | A | accent colour | black 70 px | black 170 px | black 8–12 px |
  74. | B | paper `#f4efe6` | black 70 px | black 170 px | accent 8–12 px |
  75. | C | dark `#0e0e0d`, centred | white 70 px | accent 170 px | none |
  76. | D | dark `#0e0e0d`, left-aligned | white 70 px | accent 170 px | none |
  77. - Beat 1 (`t=0`): first line slams in; beat 2 (`t=0.5`): keyword + suffix slams in.
  78. - Slam = scale `1.7 → 1`, blur `16 → 0` px, 0.11 s, `outExpo`; plus accent speed lines, radial glow and 6 px / 12 px screen shake.
  79. - Background: 600 px outlined echo text drifting horizontally; `STYLE 0X / 11` bottom-right; music drops to 6% during the card, then the style segment opens with its own hit.
  80. - Pre-render blur layers once and cross-fade with `globalAlpha` — never run `ctx.filter` per frame.
  81. ### The 120 BPM soundtrack
  82. Pure numpy/scipy synthesis — no samples, no audio model:
  83. - **Instruments**: kick (sine sweep), snare, clap, hat, crash, sub boom, noise riser, reverse crash, whoosh, plucked string, FM e-piano, FM bell, supersaw, 808, square/triangle leads, flute.
  84. - **Harmony**: A minor, one chord pair per 6-beat segment — Am/F, C/G, F/G, C/F, Am/G, Am/Em, Dm/E, C/G, Dm/G, F/G, Am/F.
  85. - **Arrangement**: pad + typing clicks → sub boom at 4.55 s, kick crescendo → 8th hats from 5.5 s → snare roll 6.5–7.95 s → reverse crash at 7.45 s. Cards drop the music to 6%; the first frame of each style segment is a six-layer hit.
  86. - **Mix**: kick-envelope sidechain (55% duck), 2.2 s synthetic convolution reverb, `tanh` soft clip, normalize to −0.6 dBFS.
  87. - **Reference measurements**: 120.0 BPM, phase 0.0 s, 86.3% of 102 strong onsets inside ±30 ms of the grid (median error 0 ms); card hits measure 8–9× the previous 300 ms of energy, style-segment hits 2.8–3.5×.
  88. ### Rendering pipeline
  89. 1. Serve the project root over HTTP (fonts, KaTeX and Three.js all same-origin; never `file://`).
  90. 2. `render-segment.mjs` launches headless Chromium, waits for `document.fonts.ready` and `window.__ready`, then for each frame calls `page.evaluate(t => renderFrame(t))`, captures via CDP `Page.captureScreenshot({ format: 'jpeg', quality: 95 })`, and pipes the JPEGs to `ffmpeg -f image2pipe -framerate 30 -i pipe:0 -c:v libx264 -preset medium -crf 16 -pix_fmt yuv420p`.
  91. 3. `concat-and-encode.sh` concatenates segment MP4s (`-f concat -safe 0 -c copy`), muxes the WAV, and runs a 2-pass encode at 3400 kbps with AAC 192 kbps.
  92. 4. Every segment is verified with `ffprobe -count_frames`; the total must equal 1830.
  93. ### QA checklist
  94. **Picture** — no console errors, no 404s (including favicon); every font passes `document.fonts.check()` with no missing CJK glyphs; 5–6 stills per style segment and a 1 fps contact sheet for the whole film; grep proves no CSS animation/rAF/`Date.now`/`Math.random`; no per-frame `ctx.filter` or large `shadowBlur`; coordinates cached before camera transforms (`getBoundingClientRect` is affected by transforms); 1920×1080 at 1×, `preserveDrawingBuffer: true`, WebGL via SwiftShader.
  95. **Audio** — spectrogram shows every hit within 30 ms of the edit table; cards drop out, style segments hit on frame one; 5.5–6.0 s fade-out; peak −0.6 dBFS with no clipping.
  96. **Assembly** — every segment's frame count equals `duration × 30`, total 1830; audio and video aligned (`-shortest`, `-t 61` if needed); H.264 `yuv420p` + AAC 48 kHz, ≈ 26 MB; a cover frame is extracted and a one-page spec sheet (frame rate / duration / styles / fonts / toolchain) is written.
  97. ## Themes
  98. A theme is not three swapped colours: it is a role palette (14 tokens), one background material, HUD specs and four accent colours. Eight themes ship in `templates/themes.js`; **omitting `?theme=` renders the original `coral-noir` visuals, pixel for pixel**.
  99. | # | id | Name | Mode | Material | Best for |
  100. |---|---|---|---|---|---|
  101. | 01 | `coral-noir` | Coral Noir / 珊瑚暗夜 | dark | film grain | default / product & tech launch |
  102. | 02 | `claude-light` | Claude Light / 橙光白 | light | warm paper | brand / knowledge / interview |
  103. | 03 | `aqua-morandi` | Aqua Morandi / 水蓝白·莫兰迪 | light | liquid glass · soft light | beauty / lifestyle / light tech |
  104. | 04 | `amber-noir` | Amber Noir / 琥珀黑金 | dark | brushed foil | premium / luxury / annual film |
  105. | 05 | `blueprint-stone` | Blueprint Stone / 蓝图纸 | light | blueprint grid | engineering / architecture / data |
  106. | 06 | `graphite-signal` | Graphite Signal / 石墨信号 | dark | matte industrial | developer / hardware / hard tech |
  107. | 07 | `celadon-paper` | Celadon Paper / 青瓷白 | light | ink wash | oriental / culture / minimal |
  108. | 08 | `crimson-theater` | Crimson Theater / 绯墨剧场 | dark | stage spotlight | fashion / art / teaser / mood |
  109. ![Three featured themes](assets/theme-previews/theme-three-up.jpg)
  110. *Three featured themes side by side: coral-noir (default), claude-light, aqua-morandi.*
  111. ![All eight themes](assets/theme-previews/theme-contact-sheet.jpg)
  112. *Contact sheet of all eight themes. Per-theme stills: `assets/theme-previews/01-coral-noir.jpg` … `08-crimson-theater.jpg`.*
  113. ![Default theme still](assets/theme-previews/01-coral-noir.jpg)
  114. *`coral-noir` — the default theme, identical to the pre-theme visuals.*
  115. Pick a theme through the query string. Both templates read it with `themeFromURL()`; aliases work (`?theme=aqua`, `?theme=claude`, `?theme=珊瑚`) and an unknown value falls back to `coral-noir`:
  116. ```bash
  117. # style segment (relative --page keeps ?theme=; the renderer appends seg/t0/speed/dur)
  118. node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --out out/01.mp4 --duration 3
  119. # big-card stills
  120. node render-segment.mjs --page /big-card.html?theme=graphite-signal --still 0.5,1.0 --outdir out/stills
  121. ```
  122. Theme choice is an intake decision, not a rendering tweak: collect the brief with `references/intake.md` (at most two rounds, lock the theme, write `brief.json`), then read the full spec in `references/themes.md`. Audit every palette change with `node scripts/theme-audit.mjs --strict` — all eight themes pass today. For a real brand colour use `accentOverride(themeRef, input)` in `themes.js` and store the returned `override` in `brief.json`; do not invent a ninth theme.
  123. ## Quick start
  124. The templates are a scaffold, not a finished film. From this repository:
  125. ```bash
  126. # 0) intake first — collect the brief, lock the theme, write brief.json (references/intake.md)
  127. # pick a theme from assets/theme-previews/theme-contact-sheet.jpg (or re-render previews in step 3)
  128. # 1) create a project and copy the templates into it
  129. mkdir -p my-showcase/segments my-showcase/shared my-showcase/fonts my-showcase/audio my-showcase/out
  130. cp templates/* my-showcase/
  131. cp scripts/* my-showcase/
  132. cp my-showcase/segment.html my-showcase/segments/01.html # your first style segment
  133. cp my-showcase/common.js my-showcase/themes.js my-showcase/segments/ # segment.html imports ./common.js and ./themes.js
  134. # 2) install the renderer inside the project (theme previews need it too)
  135. (cd my-showcase && npm i playwright) # or playwright-core; the renderer accepts either
  136. # 3) optional: render the eight theme previews + contact sheet (run from the repo root)
  137. node scripts/theme-preview.mjs --root my-showcase
  138. # 4) draft stills first (cheap) — t=0.2,0.8,1.4,2.0,2.6
  139. cd my-showcase
  140. node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --still 0.2,0.8,1.4,2.0,2.6 --outdir out/stills
  141. # 5) render one 3 s segment; the renderer starts its own ephemeral static server
  142. node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --out out/01.mp4 --duration 3
  143. # 6) verify segment frame counts (h264 / yuv420p / 1920x1080 / fps / frames)
  144. ./qa-check.sh out 30
  145. # 7) synthesize the soundtrack (8 s demo out of the box)
  146. python3 synth_audio.py --out audio/demo.wav
  147. # 8) concat + mux + 2-pass encode (defaults: duration 61, 30 fps, 3400 kbps, AAC 192k)
  148. ./concat-and-encode.sh segments.txt audio/mix.wav out/final.mp4
  149. ```
  150. `segments.txt` is the concat demuxer list, one line per segment:
  151. ```text
  152. file 'out/00-opening.mp4'
  153. file 'out/01-card.mp4'
  154. file 'out/02-style-01.mp4'
  155. ...
  156. ```
  157. Notes:
  158. - `render-segment.mjs` embeds a small static server, so a local **path** is enough (`--page /segments/01.html`); a full URL is used verbatim. Style segments take `--t0 0.35 --speed 1.4` — for a relative page the renderer appends `?seg=1&t0=&speed=&dur=`, and `common.js` maps clip time `u` to scene time `t = t0 + u·speed`.
  159. - Rendering needs no separate server: the renderer embeds one. For manual browser previews only, serve the project root on port 4600 yourself — `references/render-pipeline.md` §3 documents an optional `tools/server.mjs` (`node tools/server.mjs --port 4600`) that is not shipped, because the renderer already contains an equivalent. To click through the theme boards interactively, serve the templates directory instead: `python3 -m http.server -d templates 4600`, then open `http://localhost:4600/theme-board.html?theme=aqua-morandi` (the boards import `./themes.js` as a module, so `file://` will not work).
  160. - The templates expect a local `shared/fonts.css` with `@font-face` rules for OFL fonts you download yourself. Fonts are not bundled.
  161. - Useful env vars: `CHROME_EXE` / `FFMPEG_EXE` for the renderer; `FFMPEG` / `FFPROBE` / `VIDEO_BITRATE` / `AUDIO_BITRATE` for the shell scripts (plus `PYTHON` for `qa-check.sh`). `node render-segment.mjs --help` lists every flag.
  162. - `synth_audio.py` is a toolkit plus a runnable 8 s demo; extend `build_arrangement()` to the full 61 s timeline using `references/audio-recipes.md`.
  163. ## Install as an Agent Skill
  164. The repository is a self-contained skill folder: `SKILL.md` carries the YAML frontmatter (`name`, `description`, `license: MIT`, `compatibility`, `allowed-tools`) and the code agent reads it before acting.
  165. ```bash
  166. # DeepSeek Harness
  167. cp -r code-video-showcase ~/.dsh/skills/
  168. # Claude Code
  169. cp -r code-video-showcase ~/.claude/skills/
  170. # Generic SKILL.md-compatible agents
  171. cp -r code-video-showcase .agents/skills/
  172. ```
  173. Once installed, the skill auto-triggers on prompts such as 卡点视频 / 风格展示视频 / 纯代码做视频 / 「类似 Opus 5.5 或 DeepSeek 风格展示」 / 逐帧渲染 / 用代码做视频 / HTML Canvas 视频 / 程序化视频 — and on the English equivalents ("beat-synced showcase video", "render video frame by frame in code"). The agent then follows the ten-stage workflow, copies the templates and renders locally.
  174. ## Requirements
  175. | Component | Requirement | Why |
  176. |---|---|---|
  177. | Node.js | ≥ 20 (24 recommended) | renderer script + `playwright` |
  178. | npm packages | `playwright` or `playwright-core` (optional: `katex`) | headless Chromium driver, browser |
  179. | Browser | Playwright bundled Chromium, Chrome for Testing, or Edge | frame capture; WebGL via SwiftShader args |
  180. | FFmpeg + ffprobe | libx264, AAC, `image2pipe`; `tile`/`showspectrumpic` for analysis | encode, concat, 2-pass, contact sheets, spectrogram |
  181. | Python | ≥ 3.10 with numpy + scipy | soundtrack synthesis, audio analysis, QA script |
  182. | Fonts | all OFL, downloaded and served locally | CJK + display type; no CDN at render time |
  183. ### Platform notes
  184. - **Windows**: the renderer tries `CHROME_EXE` if set, then Playwright's bundled Chromium, then Edge (`channel: 'msedge'`); set `CHROME_EXE` to point at a specific build.
  185. - **WSL / Linux**: if the bundled download is slow, use Chrome for Testing and `executablePath`; headless Chromium may need `libnss3/libnspr4/libasound2`, obtainable without root via `apt-get download` + `dpkg-deb -x` into `~/.local/opt/chromium-libs` and `LD_LIBRARY_PATH`.
  186. - Keep `node_modules`, Python venvs, browser caches and scratch frames on the Linux filesystem: in the reference measurements `/mnt/e` wrote ~2000 small files in ~4.9 s versus ~0.05 s on ext4. Frames are piped straight to ffmpeg and never hit disk; rendering is local and CPU-bound, with no cloud service or generation API involved.
  187. ## Repo structure
  188. ```text
  189. code-video-showcase/
  190. ├─ SKILL.md # the skill itself — workflow, constraints, index
  191. ├─ README.md # this file
  192. ├─ LICENSE # MIT
  193. ├─ .gitignore / .gitattributes # ignore build output / enforce LF line endings
  194. ├─ references/
  195. │ ├─ intake.md # pre-flight brief intake + theme lock (brief.json)
  196. │ ├─ original-brief.txt # the original 61 s brief — copy and rebrand
  197. │ ├─ reference-film-analysis.md # measured breakdown of the reference (cuts/frames/audio)
  198. │ ├─ style-recipes.md # 11 styles: art direction + technique + sound
  199. │ ├─ themes.md # theme system: palettes, materials, HUD, cardColors, QA
  200. │ ├─ big-card-and-typography.md # 4 card layouts, type scale, slam parameters
  201. │ ├─ audio-recipes.md # 120 BPM arrangement, synthesis formulas, mix chain
  202. │ └─ render-pipeline.md # Playwright / FFmpeg / cross-platform setup and commands
  203. ├─ templates/
  204. │ ├─ common.js # easing, seeded random, noise/fbm, segment mode, impact
  205. │ ├─ themes.js # 8 themes: palettes, materials, HUD, cardColors/chrome/accentOverride
  206. │ ├─ segment.html # style-segment skeleton (Canvas + optional Three.js)
  207. │ ├─ big-card.html # big-card skeleton (4 layouts, slam, echo type)
  208. │ ├─ theme-board.html # single-theme preview board (?theme=<id>, 1920×1080)
  209. │ ├─ render-segment.mjs # frame-by-frame renderer -> ffmpeg image2pipe
  210. │ ├─ concat-and-encode.sh # concat + mux + 2-pass encode
  211. │ └─ synth_audio.py # numpy/scipy instrument library + arrangement demo
  212. ├─ scripts/
  213. │ ├─ analyze-reference.sh # any reference MP4 -> contact sheet/cuts/spectrogram/analysis
  214. │ ├─ theme-preview.mjs # render the eight theme previews, contact sheet and three-up
  215. │ ├─ theme-audit.mjs # theme contrast audit (--strict for CI)
  216. │ └─ qa-check.sh # verify segment MP4s (codec/pix_fmt/size/fps/frame count)
  217. └─ assets/ # evidence images and measured data
  218. ├─ contact-1fps.jpg # 1 fps contact sheet of the 61 s reference
  219. ├─ opening-tiles.jpg / style-tiles.jpg / card-tiles.jpg / flash-tiles.jpg / ending-tiles.jpg
  220. ├─ template-demo-segment.jpg / template-demo-card.jpg # stills rendered from the templates
  221. ├─ audio-spectrogram.png # log-frequency spectrogram
  222. ├─ theme-previews/ # 8 theme stills + contact sheet + three-up (see Themes)
  223. └─ audio-analysis.json / scene-cuts.txt / colors-per-second.json # measured data
  224. ```
  225. ## The 11 styles
  226. | # | Style | Core technique | Key elements | Signature sound |
  227. |---|---|---|---|---|
  228. | 01 | Flat-science explainer | Canvas 2D layered circles / triangles / dashed orbit | sun, earth, light beam, label capsules | marimba |
  229. | 02 | Math animation | Canvas 2D + DFT epicycles + KaTeX | golden heart, formulas, live N/θ | FM e-piano arpeggio + pad |
  230. | 03 | Minimal product launch | canvas type + Three.js `LatheGeometry` | metal ring, LED halo, "Nova Ring" | per-beat sub + bells |
  231. | 04 | Hand-drawn whiteboard | SVG `stroke-dashoffset` + turbulence | bulb → code → clapper, red circle | ukulele + marker noise |
  232. | 05 | Cyber glitch | Canvas gradients / perspective grid + RGB split | striped sun, city, glitch slices | distorted 16th saw + four-on-the-floor |
  233. | 06 | Ink-wash (guofeng) | Canvas fbm ridges + paper texture | mountains, red sun, boat, vertical calligraphy | guzheng pentatonic + taiko + flute |
  234. | 07 | Data visualisation | Canvas bar race + CSS 3D perspective | bars, year counter, glass card | square arpeggio + ticks |
  235. | 08 | 8-bit pixel | 240×135 canvas, pixelated 8× | robot, coins, slime, pixel HUD | chiptune + jump/coin SFX |
  236. | 09 | Code screencast | Canvas editor + typed code | file tree, line numbers, live preview | lo-fi e-piano + vinyl noise |
  237. | 10 | Three.js 3D | `Lathe`/`TorusKnot` + `PhysicalMaterial` | clay studio, glass and metal spheres | bell arpeggio + boings |
  238. | 11 | Vertical short | Canvas phone frame + pop-in UI | 9:16, step cards, comments and likes | 808 + supersaw + trap hats |
  239. Every style segment carries the same chrome: a top-left capsule with the themed index number (coral in the default theme) and style name, a bottom-right 3-second countdown, a faint brand watermark, one or two in-style labels, and no bottom subtitles.
  240. Each of the eleven segments keeps its own palette by default; the theme unifies the film through capsule/HUD chrome, `cardColors()` and `theme.accents` rather than repainting every segment — see the last section of `references/style-recipes.md`.
  241. ## Design constraints
  242. - **Deterministic frames.** Every frame is a pure function of `t`. Forbidden: CSS `transition`/`animation`, `requestAnimationFrame` in the page, `Date.now()`, `performance.now()`, `Math.random()`. Use `mulberry32(seed)` and value noise/fbm instead.
  243. - **The renderer drives time.** A page exposes `window.DURATION`, `window.renderFrame(t)`, `window.__ready` (and optionally `window.__bootError`); the renderer calls `renderFrame(i/fps)` — the page never schedules itself.
  244. - **No baked subtitles.** All text is part of the composition (capsules, HUD, labels); bottom subtitle bars are banned.
  245. - **Themes are data.** Every colour comes from `templates/themes.js` (`?theme=` → `chrome(theme)`, `cardColors(theme, layout)`, `drawThemeBackground`); never hard-code `#d97757` in a page.
  246. - **WebGL specifics.** `{ preserveDrawingBuffer: true }`, launch flags `--use-angle=swiftshader --enable-webgl --ignore-gpu-blocklist --enable-unsafe-swiftshader`, camera motion by parameter, never by wall clock.
  247. - **Cheap frames.** Pre-render blur/noise/paper layers once, cross-fade with alpha, and inspect five stills before a full render; avoid per-frame `ctx.filter` and wide `shadowBlur` (per-frame filters are 10×+ slower under software rendering); cache layout coordinates before camera transforms.
  248. - **One page, one segment.** No shared runtime state between pages; visuals and audio import the same timeline constants.
  249. - **OFL fonts only, served locally.** Load with `document.fonts.load(...)` for every family and weight, then `document.fonts.ready`, then set `window.__ready`.
  250. ## License & credits
  251. Released under the **MIT License** — see [LICENSE](LICENSE).
  252. Credits and provenance:
  253. - The structure, timing and visual grammar come from a frame-by-frame analysis of a 61 s reference style-showcase video. The analysis is documented in `references/reference-film-analysis.md`, with evidence in `assets/`.
  254. - **Original prompt credit:** the seed prompt behind this skill came from the creator **Mixx.ftr**; the templates, theme system, preview tooling, render pipeline and QA checklist in this repository are an independent engineering extension built on top of it.
  255. - The production brief that this skill operationalizes is included verbatim as `references/original-brief.txt`.
  256. - No third-party code or media assets are bundled. All artwork is meant to be drawn at runtime; the soundtrack is synthesized.
  257. - Fonts are **not** bundled — download OFL-licensed font files yourself and serve them locally.
  258. - The coral `#d97757` brand colour and the sample copy are placeholders; replace them with your own brand and script.
  259. ## Language
  260. This README is bilingual: English first, Chinese below. `SKILL.md` itself is written in Chinese and is the authoritative source for the workflow. [跳到中文](#中文).
  261. ## 中文
  262. **这是一个「用代码做视频」的 Agent Skill:** 画面由 HTML/Canvas/SVG/Three.js 逐帧绘制,配乐由 Python(numpy/scipy)纯合成,最后交给 FFmpeg 合成 30–90 秒的卡点风格展示片。全程不调用任何视频、图像或音乐生成模型,每一帧都是时间 `t` 的纯函数,可复现、可逐帧检查。
  263. ### 这个项目是什么
  264. 它不是模型,而是一套可复用的制作方法。内容来自对一支 61 秒风格展示样片的逐帧拆解:剪辑结构公式、4 套大字卡版式、11 种风格的「美术 + 技术 + 音色」配方、120 BPM 配乐、Playwright 逐帧渲染管线、质检清单,以及可直接运行的模板。样片的结构是固定句式:开场 8 秒 → 11 轮 × 4 秒(大字卡 1 秒 + 风格段 3 秒)→ 「还有更多?」卡 1 秒 → 八连闪 2 秒 → 结尾 6 秒,合计 61 秒 / 1830 帧。公式可推广到任意风格数 `N`,30–90 秒的短片都能套用。
  265. ### 仓库里有什么
  266. - **十阶段工作流**:从需求定稿、剪辑表、环境准备,到逐段实现、配乐、合成与质检(见 `SKILL.md`)。
  267. - **时间结构公式**:总时长 = `O + N·R + 1 + 2 + E`;每段帧数 `round(duration × 30)`,全片合计必须为 1830。
  268. - **大字卡系统**:强调色底 / 米白底 / 黑底居中 / 黑底左对齐 4 套版式;砸入缩放 1.7→1、模糊 16→0 px、0.11 秒 `outExpo`;速度线、径向光晕、6/12 px 抖动、600 px 描边回声字。
  269. - **8 套主题配色**:珊瑚暗夜(默认,与原版逐值一致)、橙光白、水蓝白·莫兰迪、琥珀黑金、蓝图纸、石墨信号、青瓷白、绯墨剧场。一套主题 = 角色色板 + 材质 + HUD 规格 + 点缀色;数据源 `templates/themes.js`,规范见 `references/themes.md`,选主题走 `references/intake.md`。
  270. - **11 种风格配方**:每种都给出调色板、构图、6 拍动效表、技术实现要点和专属音色。
  271. - **120 BPM 配乐方案**:A 小调、纯 numpy/scipy 合成;大字卡音乐压到 6% 形成 drop-out,风格段第一帧是六层叠加的「啪」;侧链 55%、2.2 秒混响、`tanh` 软削波、归一化到 −0.6 dBFS。
  272. - **渲染管线与质检**:服务器 → Playwright 无头 Chromium → CDP 截帧 JPEG q95 → `image2pipe` → libx264 crf16 → concat → 2-pass 3400 kbps + AAC 192k;质检覆盖画面、音频、合成三组检查项,外加 1 fps 接触表、频谱图与 `ffprobe` 帧数复核。
  273. - **参考样片拆解与原始任务书**:`references/reference-film-analysis.md` 记录实测切点、画面与音频数据;`references/original-brief.txt` 是可改品牌直接复用的完整任务书。
  274. ### 预览说明
  275. 仓库里**没有**提交成片视频,参考样片文件也不随仓库分发。预览素材是样片拆解图和模板占位实拍帧,图注与说明见上方英文 [Preview](#preview) 一节:`assets/contact-1fps.jpg`(全片 1 fps 接触表)、`style-tiles.jpg`(11 种风格各取一帧)、`card-tiles.jpg`(12 张大字卡)、`audio-spectrogram.png`(音频频谱)、`template-demo-card.jpg`(模板占位实拍)。
  276. 主题预览图单独放在 `assets/theme-previews/`:三拼对比 `theme-three-up.jpg`、全集联系表 `theme-contact-sheet.jpg`、单主题 `01-coral-noir.jpg`–`08-crimson-theater.jpg`,见下文 [主题配色](#主题配色)。
  277. ### 主题配色
  278. 主题不是「换三个颜色」,而是**角色色板(14 个 token)+ 材质 + HUD 规格 + 点缀色**四层一起换。`templates/themes.js` 内置 8 套主题;**不传 `?theme=` 时渲染原版 `coral-noir` 画面,逐像素一致**。
  279. | # | id | 名称 | 明暗 | 主材质 | 适合内容 |
  280. |---|---|---|---|---|---|
  281. | 01 | `coral-noir` | 珊瑚暗夜 / Coral Noir | 深色 | 胶片颗粒 | 默认 / 科技发布 / 产品片 |
  282. | 02 | `claude-light` | 橙光白 / Claude Light | 浅色 | 纸面柔光 | 品牌 / 知识 / 访谈 |
  283. | 03 | `aqua-morandi` | 水蓝白·莫兰迪 / Aqua Morandi | 浅色 | 液态玻璃 · 柔光 | 美妆 / 生活方式 / 轻科技 |
  284. | 04 | `amber-noir` | 琥珀黑金 / Amber Noir | 深色 | 金属烫金 | 高端 / 奢品 / 年度片 |
  285. | 05 | `blueprint-stone` | 蓝图纸 / Blueprint Stone | 浅色 | 蓝图网格 | 工程 / 建筑 / 数据 |
  286. | 06 | `graphite-signal` | 石墨信号 / Graphite Signal | 深色 | 哑光工业 | 开发者 / 硬件 / 硬核科技 |
  287. | 07 | `celadon-paper` | 青瓷白 / Celadon Paper | 浅色 | 水墨晕染 | 东方 / 文化 / 极简 |
  288. | 08 | `crimson-theater` | 绯墨剧场 / Crimson Theater | 深色 | 舞台聚光 | 时尚 / 艺术 / 预告 |
  289. ![三套主推主题](assets/theme-previews/theme-three-up.jpg)
  290. *三套主推主题对比:珊瑚暗夜(默认)/ 橙光白 / 水蓝白·莫兰迪。*
  291. ![8 套主题联系表](assets/theme-previews/theme-contact-sheet.jpg)
  292. *8 套主题全集。单主题大图:`assets/theme-previews/01-coral-noir.jpg` … `08-crimson-theater.jpg`。*
  293. ![默认主题静帧](assets/theme-previews/01-coral-noir.jpg)
  294. *`coral-noir` 默认主题,与原版视觉一致。*
  295. 选主题用查询参数:两个模板都由 `themeFromURL()` 读取,支持别名(`?theme=aqua`、`?theme=claude`、`?theme=珊瑚`),未知值回退 `coral-noir`:
  296. ```bash
  297. # 风格段(相对 --page 保留 ?theme=,渲染器自动追加 seg/t0/speed/dur)
  298. node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --out out/01.mp4 --duration 3
  299. # 大字卡静帧
  300. node render-segment.mjs --page /big-card.html?theme=graphite-signal --still 0.5,1.0 --outdir out/stills
  301. ```
  302. 主题选择属于「信息采集」,不是渲染参数:先按 `references/intake.md` 收信息(最多 2 轮)、锁定主题、写 `brief.json`,完整规范见 `references/themes.md`。任何配色改动都跑 `node scripts/theme-audit.mjs --strict`——当前 8 套全部通过。用户有真实品牌色时用 `themes.js` 的 `accentOverride(themeRef, input)`,把返回的 `override` 写进 `brief.json`,不要自创第 9 套主题。
  303. ### 快速开始
  304. 模板是脚手架,不是成片。在本仓库根目录执行:
  305. ```bash
  306. # 0) 先采集信息——按 references/intake.md 锁定主题,把 brief.json 写进项目根
  307. # 看 assets/theme-previews/theme-contact-sheet.jpg 选主题(或在第 3 步重新渲染预览)
  308. # 1) 建项目并复制模板
  309. mkdir -p my-showcase/segments my-showcase/shared my-showcase/fonts my-showcase/audio my-showcase/out
  310. cp templates/* my-showcase/
  311. cp scripts/* my-showcase/
  312. cp my-showcase/segment.html my-showcase/segments/01.html # 第一段风格片
  313. cp my-showcase/common.js my-showcase/themes.js my-showcase/segments/ # segment.html 里 import 的是 ./common.js 与 ./themes.js
  314. # 2) 在项目里安装渲染器(主题预览也要用它)
  315. (cd my-showcase && npm i playwright) # 或 playwright-core,渲染器两者都接受
  316. # 3) 可选:渲染 8 套主题预览 + 联系表(默认写入仓库 assets/theme-previews/,在仓库根目录跑)
  317. node scripts/theme-preview.mjs --root my-showcase
  318. # 4) 先出静帧(便宜)—— t=0.2/0.8/1.4/2.0/2.6
  319. cd my-showcase
  320. node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --still 0.2,0.8,1.4,2.0,2.6 --outdir out/stills
  321. # 5) 渲染一个 3 秒片段;渲染器会自启临时静态服务器
  322. node render-segment.mjs --page /segments/01.html?theme=aqua-morandi --out out/01.mp4 --duration 3
  323. # 6) 校验分段帧数(h264 / yuv420p / 1920x1080 / fps / 帧数)
  324. ./qa-check.sh out 30
  325. # 7) 合成配乐(默认先跑 8 秒 demo 验证环境)
  326. python3 synth_audio.py --out audio/demo.wav
  327. # 8) 拼接 + 混音 + 2-pass 输出(默认 61 秒、30 fps、3400 kbps、AAC 192k)
  328. ./concat-and-encode.sh segments.txt audio/mix.wav out/final.mp4
  329. ```
  330. 补充说明:
  331. - `render-segment.mjs` 自带静态服务器,`--page` 传本地路径即可,完整 URL 原样使用。风格段可传 `--t0 0.35 --speed 1.4`:相对路径会自动拼成 `?seg=1&t0=&speed=&dur=`,`common.js` 按 `t = t0 + u*speed` 把片段时间映射为场景时间。
  332. - 渲染不需要另起服务器(渲染器已内置)。只有在浏览器里手动预览时才需要自己起一个监听 4600 端口的服务器;`references/render-pipeline.md` 第 3 节记录了一个可选的 `tools/server.mjs`(`node tools/server.mjs --port 4600`),它没有随仓库分发,因为渲染器内已有等价实现。想交互式点开主题预览板时,改成伺服 `templates/` 目录:`python3 -m http.server -d templates 4600`,然后打开 `http://localhost:4600/theme-board.html?theme=aqua-morandi`(预览板以模块方式 import `./themes.js`,`file://` 打不开)。
  333. - `templates/` 里的 HTML 引用 `/shared/fonts.css`,需要你自己下载 OFL 字体并写 `@font-face`;字体不随仓库分发。常用环境变量:渲染器的 `CHROME_EXE` / `FFMPEG_EXE`,脚本的 `FFMPEG` / `FFPROBE` / `VIDEO_BITRATE` / `AUDIO_BITRATE`。
  334. - `synth_audio.py` 是「音色库 + 8 秒可运行 demo」,完整 61 秒编排按 `references/audio-recipes.md` 扩展 `build_arrangement()`。
  335. ### 安装为 Agent Skill
  336. 整个仓库就是一个技能目录,`SKILL.md` 带 YAML frontmatter(`name`、`description`、`license: MIT`、`compatibility`、`allowed-tools`)。把文件夹复制到对应技能目录即可:DeepSeek Harness 为 `~/.dsh/skills/`,Claude Code 为 `~/.claude/skills/`,通用 SKILL.md 兼容 agent 为 `.agents/skills/`。
  337. 安装后,提到「卡点视频」「风格展示视频」「纯代码做视频」「类似 Opus 5.5 / DeepSeek 风格展示」「逐帧渲染」「用代码做视频」「HTML Canvas 视频」「程序化视频」时会自动触发;Agent 会按十阶段工作流执行、复制模板并在本地渲染。
  338. ### 环境要求
  339. | 组件 | 要求 | 用途 |
  340. |---|---|---|
  341. | Node.js | ≥ 20(推荐 24) | 渲染脚本与 `playwright` |
  342. | npm 包 | `playwright` 或 `playwright-core`(可选 `katex`) | 无头 Chromium 驱动 |
  343. | 浏览器 | Playwright 自带 Chromium、Chrome for Testing 或 Edge | 逐帧截图;WebGL 走 SwiftShader |
  344. | FFmpeg + ffprobe | 含 libx264、AAC、`image2pipe`;分析需 `tile` / `showspectrumpic` | 编码、拼接、2-pass、接触表、频谱图 |
  345. | Python | ≥ 3.10 + numpy + scipy | 配乐合成、音频分析与质检脚本 |
  346. | 字体 | 全部 OFL、本地文件 | 中文与展示字体;渲染时不依赖 CDN |
  347. 平台要点:Windows 下渲染器会依次尝试自带 Chromium → Chrome for Testing → Edge(`channel: 'msedge'`);WSL/Linux 下若浏览器下载慢可用 Chrome for Testing + `executablePath`,缺 `libnss3/libnspr4/libasound2` 时可用 `apt-get download` + `dpkg-deb -x` 解到用户目录并设 `LD_LIBRARY_PATH`。`node_modules`、venv、浏览器缓存和临时帧建议放 Linux 文件系统:实测 `/mnt/e` 写 2000 个小文件约 4.9 秒,ext4 约 0.05 秒;逐帧渲染直接管道给 ffmpeg,不落盘。整个过程在本地 CPU 完成,不调用云端服务。
  348. ### 11 种风格速查
  349. | # | 风格 | 核心手法 | 关键元素 | 专属音色 |
  350. |---|---|---|---|---|
  351. | 01 | 扁平插画科普 | Canvas 2D 分层圆 / 三角 / 虚线轨道 | 太阳、地球、光束、标签胶囊 | 马林巴 |
  352. | 02 | 数学动画 | Canvas 2D + DFT 本轮 + KaTeX | 金色心形、公式、实时 N/θ | FM 电钢琶音 + 铺底 |
  353. | 03 | 极简发布会 | Canvas 大字 + Three.js `LatheGeometry` | 金属戒指、LED 环、Nova Ring | 逐拍重低音 + 钟声 |
  354. | 04 | 手绘白板 | SVG `stroke-dashoffset` + turbulence | 灯泡 → 代码 → 场记板、红圈 | 尤克里里 + 马克笔摩擦 |
  355. | 05 | 赛博故障 | Canvas 渐变 / 透视网格 + RGB 分离 | 条纹落日、城市、故障切片 | 失真锯齿 16 分 + 四拍底鼓 |
  356. | 06 | 水墨国风 | Canvas fbm 山峦 + 宣纸纹理 | 远山、红日、渔舟、竖排书法 | 古筝五声 + 太鼓 + 笛 |
  357. | 07 | 数据可视化 | Canvas 条形赛跑 + CSS 3D 透视 | 条形图、年份、玻璃卡 | 方波琶音 + 滴答 |
  358. | 08 | 8-bit 像素 | 240×135 低分辨率 + pixelated | 机器人、金币、史莱姆、像素 HUD | 芯片音乐 + 跳跃/金币 |
  359. | 09 | 代码录屏 | Canvas 编辑器 + 逐字代码 | 文件树、行号、实时预览 | lo-fi 电钢 + 黑胶噪声 |
  360. | 10 | Three.js 三维 | `Lathe`/`TorusKnot` + `PhysicalMaterial` | 粘土影棚、玻璃球、金属球 | 钟声琶音 + 弹跳 |
  361. | 11 | 竖屏短视频 | Canvas 手机壳 + 弹出动画 | 9:16、步骤卡、评论/点赞 | 808 + 超级锯齿 + trap 镲 |
  362. 每段统一装置:左上角主题化编号胶囊标签(默认主题为珊瑚)、右下 3 秒倒计时、右上淡色品牌水印、1–2 个风格内小标签;不使用底部字幕。
  363. 11 个风格段默认保留各自色板;主题通过胶囊/HUD、`cardColors()` 与 `theme.accents` 统一整片气质,而不是把每段重刷一遍——换色规则见 `references/style-recipes.md` 末节。
  364. ### 确定性约束
  365. - 画面是 `t` 的纯函数:禁止 CSS `transition`/`animation`、页面内 `requestAnimationFrame`、`Date.now`、`performance.now`、`Math.random`;随机一律用 `mulberry32(seed)`。
  366. - 页面只暴露 `window.DURATION`、`window.renderFrame(t)`、`window.__ready`(可选 `window.__bootError`),由渲染器逐帧驱动,页面自己不做动画循环。
  367. - 字体只用 OFL、本地同源加载;渲染前逐个 `document.fonts.load()`,再等 `document.fonts.ready`。
  368. - 主题只从 `templates/themes.js` 取色(`?theme=` → `chrome(theme)` / `cardColors(theme, layout)` / `drawThemeBackground`),禁止在页面里写死 `#d97757`。
  369. - 模糊、纸纹、噪声等重图层预渲染一次再交叉淡化;避免逐帧 `ctx.filter` 和大面积 `shadowBlur`;镜头变换前缓存坐标。
  370. - 一个 HTML 只做一个片段;画面和音频共用同一份剪辑表时间常数。
  371. ### 许可与致谢
  372. 以 **MIT License** 发布,详见 [LICENSE](LICENSE)。
  373. - 方法、时间结构与视觉语法来自对一支 61 秒参考样片的逐帧拆解,分析见 `references/reference-film-analysis.md`,证据图在 `assets/`。
  374. - **原始提示词致谢:** 本技能的起点是创作者 **Mixx.ftr** 的提示词;仓库中的模板、主题系统、预览工具、渲染管线与质检是在其基础上独立完成的工程化扩展。
  375. - 驱动整个技能的原始任务书完整保留在 `references/original-brief.txt`,可改品牌直接复用。
  376. - 仓库不包含任何第三方代码或媒体素材;画面在运行时绘制,配乐实时合成。
  377. - 字体不随仓库分发,请自行下载 OFL 字体并在本地提供服务。
  378. - 珊瑚色 `#d97757` 与样片文案是占位示例,正式制作时替换成自己的品牌与脚本。
  379. ---
  380. ## Star History / Star 历史
  381. [![Star History Chart](https://api.star-history.com/svg?repos=Moessif/code-video-showcase&type=Date)](https://www.star-history.com/#Moessif/code-video-showcase&Date)
  382. > Star History 图的生成与嵌入方法参考:[如何拥有漂亮的 GitHub Star History 折线图](https://blog.csdn.net/SoulmateY/article/details/135317109)(CSDN)。

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.