---
catalog_id: "P-004"
kind: "pattern"
domain: "frontend"
domain_label: "前端动效 / Frontend & Motion"
date: "2026-11-26"
title: "确定性代码成片帧契约与无损流式渲染管线（Deterministic Code-Film Contract）"
verdict: "纯时间函数、单主时钟与无头流式直写消除代码成片漂移"
summary: "以纯时间函数 frame -> pixels、timing.json 节拍主时钟（+1 帧声画确认）、闭式弹簧阻尼（1.0/0.8/0.5）、Mulberry32 种子随机、0..N-1 无缝循环及无头 GPU 流式直写 FFmpeg 消除掉帧、漂移与静帧撕裂。"
summary_en: "Stops frame drops and drift via pure frame->pixels functions, timing.json clocks, closed-form springs, Mulberry32 RNG, and GPU-to-FFmpeg pipes."
canonical_url: "https://oumuatown.com/patterns/deterministic-code-film-contract/"
markdown_url: "https://oumuatown.com/patterns/deterministic-code-film-contract.md"
og_image_zh: "https://oumuatown.com/og/zh/P-004.png"
og_image_en: "https://oumuatown.com/og/en/P-004.png"
cite_count: 52
tags:
  - "pattern"
  - "deterministic-rendering"
  - "video-pipeline"
  - "remotion"
  - "hyperframes"
  - "motion-canvas"
  - "threejs"
  - "ffmpeg"
github_repos:
  - "https://github.com/remotion-dev/remotion/tree/53975c8"
  - "https://github.com/heygen-com/hyperframes/tree/61cea64"
  - "https://github.com/motion-canvas/motion-canvas/tree/7b91435"
  - "https://github.com/mrdoob/three.js/tree/940edbc"
  - "https://github.com/jdhruv14/line-art-animation/tree/c43d698"
  - "https://github.com/finktheartist/sakuga-vfx/tree/c3dabb1"
  - "https://github.com/rough-stuff/rough/tree/56a2762"
  - "https://github.com/forward-future/scarlet/tree/fcb077e"
  - "https://github.com/ffmpeg/ffmpeg/tree/64b26fd"
  - "https://github.com/sarpstar/cinecode/tree/c8a3e75"
  - "https://github.com/kiselas/every-frame-is-code/tree/603357f"
  - "https://github.com/mylxsw/cinematic-video-skill/tree/0fbcccc"
  - "https://github.com/sub-level/marketing-videos/tree/696073f"
  - "https://github.com/berlinify/motion-lab/tree/06daab8"
  - "https://github.com/leonxlnx/escapement/tree/02cf7a4"
  - "https://github.com/vibegameengine/video-motion-craft/tree/c17ab30"
  - "https://github.com/xikhar/papercraft/tree/30e9aaf"
  - "https://github.com/huangserva/manhattan-free-roam/tree/bb92af6"
  - "https://github.com/andrewalumkal/visuallearning.skill/tree/14799af"
  - "https://github.com/finiking/model-lab/tree/71e379c"
  - "https://github.com/godotengine/godot/tree/7c97c29"
  - "https://github.com/greensock/gsap/tree/5e6c35f"
  - "https://github.com/harleycoops/math-to-manim/tree/0457f8c"
  - "https://github.com/motiondivision/motion/tree/6390e6d"
  - "https://github.com/nexu-io/opengame/tree/e931a796a"
  - "https://github.com/nexu-io/openmotion/tree/b6846fd"
  - "https://github.com/niazmorshed2007/reanimate/tree/3f7a55a"
  - "https://github.com/patch-gg/pixelfx/tree/5294518"
  - "https://github.com/pmndrs/react-three-fiber/tree/d74622e"
  - "https://github.com/remotion-dev/claude-code-plugin/tree/f96c742"
  - "https://github.com/tejashmakwana/motionmaxxing/tree/8c8ec0f"
  - "https://github.com/theatre-js/theatre/tree/6ea82b9"
---

# P-004 · 确定性代码成片帧契约与无损流式渲染管线（Deterministic Code-Film Contract）

> **结论 / Verdict**: 纯时间函数、单主时钟与无头流式直写消除代码成片漂移
> **EN Summary**: Stops frame drops and drift via pure frame->pixels functions, timing.json clocks, closed-form springs, Mulberry32 RNG, and GPU-to-FFmpeg pipes.

## Provenance & Evidence

- Referenced Repository: https://github.com/remotion-dev/remotion/tree/53975c8
- Referenced Repository: https://github.com/heygen-com/hyperframes/tree/61cea64
- Referenced Repository: https://github.com/motion-canvas/motion-canvas/tree/7b91435
- Referenced Repository: https://github.com/mrdoob/three.js/tree/940edbc
- Referenced Repository: https://github.com/jdhruv14/line-art-animation/tree/c43d698
- Referenced Repository: https://github.com/finktheartist/sakuga-vfx/tree/c3dabb1
- Referenced Repository: https://github.com/rough-stuff/rough/tree/56a2762
- Referenced Repository: https://github.com/forward-future/scarlet/tree/fcb077e
- Referenced Repository: https://github.com/ffmpeg/ffmpeg/tree/64b26fd
- Referenced Repository: https://github.com/sarpstar/cinecode/tree/c8a3e75
- Referenced Repository: https://github.com/kiselas/every-frame-is-code/tree/603357f
- Referenced Repository: https://github.com/mylxsw/cinematic-video-skill/tree/0fbcccc
- Referenced Repository: https://github.com/sub-level/marketing-videos/tree/696073f
- Referenced Repository: https://github.com/berlinify/motion-lab/tree/06daab8
- Referenced Repository: https://github.com/leonxlnx/escapement/tree/02cf7a4
- Referenced Repository: https://github.com/vibegameengine/video-motion-craft/tree/c17ab30
- Referenced Repository: https://github.com/xikhar/papercraft/tree/30e9aaf
- Referenced Repository: https://github.com/huangserva/manhattan-free-roam/tree/bb92af6
- Referenced Repository: https://github.com/andrewalumkal/visuallearning.skill/tree/14799af
- Referenced Repository: https://github.com/finiking/model-lab/tree/71e379c
- Referenced Repository: https://github.com/godotengine/godot/tree/7c97c29
- Referenced Repository: https://github.com/greensock/gsap/tree/5e6c35f
- Referenced Repository: https://github.com/harleycoops/math-to-manim/tree/0457f8c
- Referenced Repository: https://github.com/motiondivision/motion/tree/6390e6d
- Referenced Repository: https://github.com/nexu-io/opengame/tree/e931a796a
- Referenced Repository: https://github.com/nexu-io/openmotion/tree/b6846fd
- Referenced Repository: https://github.com/niazmorshed2007/reanimate/tree/3f7a55a
- Referenced Repository: https://github.com/patch-gg/pixelfx/tree/5294518
- Referenced Repository: https://github.com/pmndrs/react-three-fiber/tree/d74622e
- Referenced Repository: https://github.com/remotion-dev/claude-code-plugin/tree/f96c742
- Referenced Repository: https://github.com/tejashmakwana/motionmaxxing/tree/8c8ec0f
- Referenced Repository: https://github.com/theatre-js/theatre/tree/6ea82b9
- Verified Source Citations (#Lxx): 52
- Web Reader: https://oumuatown.com/patterns/deterministic-code-film-contract/

# 确定性代码成片帧契约与无损流式渲染管线（Deterministic Code-Film Contract）

## 触发场景（When to Use）

- **什么时候应当采用本模式**：
  - 使用代码生成可控动画短片、品牌宣传片、科普解释视频或 WebGL/3D 动效导出成片（覆盖 `remotion-explainer-video`、基于 `prender.mjs` 的 `opuscar-explainer-video`、以及 HTML/Canvas/p5.js/Three.js 驱动的 `yiji-motion-video` 等管线）。
  - 需要多线程/多 Tab 并行抽帧或卸载至云端 GPU（如 Colab L4）分片渲染、并严格保证任意冷跳转与重跑像素一致。
- **什么时候不该用（过度设计信号）**：
  - 仅用于一次性实拍口播剪辑、无需代码生成画面的纯素材拼接，或无需离线成片的常规网页交互微动效（普通 UI 交互遵循 `greensock/gsap-skills` 即可）。

## 问题本质

- 浏览器屏幕录制与基于墙钟（wall-clock `Date.now` / `performance.now` / `requestAnimationFrame`）的实时动画在离线高画质导出下必然失效：Headless Chromium 后台标签页会将 `rAF` 节流至 `1–2 fps`，编码反压会让 `dt` 剧烈抖动，跨帧状态积分（`pos += vel * dt`）导致“顺播第 300 帧”与“并发 Worker 冷跳第 300 帧”画面分叉，非种子化的 `Math.random` 引发闪烁，而磁盘 PNG 中间文件写入又会拖垮 I/O 与编码吞吐。
- 本模式将动画从“依赖实时时钟的过程式模拟”重构为**纯时间映射 `UI = f(t)` + 单一节拍主时钟 + 零磁盘流式 FFmpeg 编码**。

## 标准解法与最小实现骨架

### 1. 五类纯时间运行契约与冷跳转不变量（2026-11-26 实证）

任意一帧画面只允许作为离散帧号 `i` 或时间 `t = i / fps` 的纯函数求值，并通过 **Seek Check 不变量**校验：**从零冷跳转到第 300 帧的渲染像素，必须与从第 0 帧连续步进到第 300 帧完全一致**。

| 技术栈 | 纯时间入口 / 时钟接管机制 | 就绪栅栏与随机寻址策略 | 源码锚点（2026-11-26） |
|---|---|---|---|
| **单文件 HTML / Canvas / WebGL** | `window.renderAt(t)`；`?render=1` 关闭 `setAnimationLoop` | `window.__ready = true`（字体、`.glb`、纹理全部就绪后置位）；同类钩子包括 `?debug` + `window.__step(s)`、`SakugaFX.paused` + `advance(1/60)`、`window.__scarletFrame(ms)` | [Fable 5.2 Playbook](../articles/2026-11-26-fable-5-2-motion-playbook.md) · [`JDhruv14/line-art-animation@c43d698`](../repos/JDhruv14__line-art-animation.md) · [`finktheartist/sakuga-vfx@c3dabb1`](../repos/finktheartist__sakuga-vfx.md) · [`Forward-Future/scarlet@fcb077e`](../repos/Forward-Future__scarlet.md) |
| **原生 HTML / CSS / WAAPI / GSAP** | 文件服务器注入 `VIRTUAL_TIME_SHIM` 劫持 `Date`、`performance.now`、`rAF`、`setTimeout`/`setInterval` 最小堆 | 13 个 `RuntimeDeterministicAdapter`（含 `CSSAnimation`/`Element.prototype.animate` 定格）+ `window.__renderReady` + Worker `t>0` 首帧先跑 `seekToTime(0)`；`non_deterministic_code` 静态拦截随机/时钟 API | [`heygen-com/hyperframes@7c217d9`](../repos/heygen-com__hyperframes.md)（`fileServer.ts#L228-L437`、`init.ts#L5594-L5617`、`rules/core.ts#L912-L994`） |
| **React 声明式组件树** | `window.remotion_setFrame(f, comp, attempt)` + `useCurrentFrame` + `<Sequence>` | `delayRender` / `continueRender` 句柄池记录建柄调用栈；未释放时阻断截图并在超时打印悬空句柄标签 | [`remotion-dev/remotion@53975c8`](../repos/remotion-dev__remotion.md)（`TimelineContext.tsx#L124-L150`、`delay-render.ts#L98-L313`、`seek-to-frame.ts#L101-L128`） |
| **Three.js 3D（r187）** | 废弃墙钟 `Clock`，显式 `Timer.update(timestamp)`；离线用 `AnimationMixer.setTime(t)`（清零归位后 `update(t)`） | 传入固定步长 `composer.render(1 / fps)` 并以 `OutputPass` 统一执行色调映射与 sRGB 转码 | [`mrdoob/three.js@940edbc`](../repos/mrdoob__three.js.md)（`Clock.js#L6-L62`、`Timer.js#L156-L174`、`AnimationMixer.js#L722-L733`、`EffectComposer.js#L214-L224`） |
| **TypeScript 生成器协程** | 每次 `.next` 步进 1 帧；`Thread` 同步维护逻辑累加 `time` 与离散 `fixedTime` 消除亚帧舍入漂移 | `DependencyContext.collectPromise` 渲染前汇聚异步资产；回跳时 `PlaybackManager.seek` 重置到场景 `firstFrame` 并纯逻辑快进重放 | [`motion-canvas/motion-canvas@7b91435`](../repos/motion-canvas__motion-canvas.md)（`threads.ts#L55-L115`、`Thread.ts#L37-L49`、`PlaybackManager.ts#L83-L187`） |

```javascript
// 通用单文件确定性骨架（适配 Three.js / Canvas 2D / p5.js / SVG）
window.__ready = false;
window.renderAt = (t) => {
  updateSceneFromClosedForm(t);          // 严禁读取 Date.now() / performance.now() 或累加 pos += vel * dt
  renderer.render(scene, camera);        // Three.js 若用 EffectComposer 则传 composer.render(1 / FPS)
};
const isHeadlessRender = new URLSearchParams(location.search).has("render");
if (!isHeadlessRender) {
  renderer.setAnimationLoop((ms) => window.renderAt((ms / 1000) % DURATION));
}
await Promise.all([document.fonts.ready, loadAllTexturesAndGlb()]);
window.__ready = true;
```

### 2. 可复现种子随机（Mulberry32 & Park-Miller LCG）

在粒子、星辰、噪点与手绘抖动中彻底替换原生 `Math.random` 与 `crypto.getRandomValues`：
- **Mulberry32 帧锁定**（参考 `remotion-dev/remotion@53975c8` `random.ts#L1-L46` 与 `heygen-com/hyperframes@7c217d9` `reseedRngFromTime(safeTimeMs)` in `fileServer.ts#L248-L286`）：每帧以时间或稳定字符串哈希重设种子，确保多线程乱序抓取结果完全一致。
- **可控“手绘沸腾线（Line Boil）”**：参考 `rough-stuff/rough@56a2762` 31 位 Park-Miller LCG（`src/math.ts#L12-L18`），令 `seed = baseSeed + Math.floor(t * boilFps)`（如 `boilFps = 6` 或 `8`），避免 60 fps 下每帧随机乱闪。注意 `rough` 的 `DotFiller`（`src/fillers/dot-filler.ts#L41-L42`）仍直接调用 `Math.random`，确定性成片应避开 `fillStyle: 'dots'` 或改写其随机源。

```javascript
export function mulberry32(seed) {
  let a = seed >>> 0;
  return () => {
    a = (a + 0x6D2B79F5) | 0;
    let t = Math.imul(a ^ (a >>> 15), 1 | a);
    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
  };
}
```

### 3. `timing.json` 节拍主时钟与 `+1 帧` 声画确认律

- **File #1 先写时钟**：先由节拍计算工具生成唯一真相源 `timing.json`（或 `cues.json`），再编写任何镜头与拟音代码，严禁由 LLM 心算时间戳：
  $$\text{frames\_per\_beat} = \frac{\text{fps} \times 60}{\text{BPM}}$$
- **视觉先达、听觉 `+1 帧` 确认**：所有撞击/落点/切镜的合成音效与拟音触发帧均设为 **`impact_frame + 1`**（60 fps 下延后 `16.7 ms`）。
- **多轨防漂移扩展**：涉及外部录音与剪切时，参考 `Forward-Future/scarlet@fcb077e` 采用有理数分数 `Q { n, d }` 锚定整帧（`rational.ts#L4-L38`），并对完整输出混音轨单遍生成连续 AAC 流，防止分段编码的 `1024-sample` priming 填充产生累积错位（`segments.ts#L65-L87`）。

### 4. 闭式解析弹簧阻尼（`1.0 / 0.8 / 0.5`）与体积守恒

严禁使用跨帧欧拉积分累加弹簧状态，全部弹性位移必须写成时间 `t` 的闭式解析函数（$\zeta = c / (2\sqrt{km})$）：

| 阻尼比 $\zeta$ | 物理特性与过冲 | 适用对象 | 典型参数实测（`1.7 m` 坠落, $\omega = 24\text{ rad/s}$） |
|---|---|---|---|
| **`1.0`** | 临界阻尼，0% 回弹 | UI 控件、文字排版、数据信息层 | 触地即停，稳重克制，压扁比 `0.77` |
| **`0.8`** | 轻微单次过冲（~7%） | 卡片、产品展示、Logo 落位 | 单次轻弹（`12 cm`）后快速收敛 |
| **`0.5`** | 明显二次回弹（~24%） | 卡通角色、品牌吉祥物、拟人动作 | 连续回弹 `41 → 10 → 2.4 cm`，滚转 `±0.11 rad`，压扁比 `0.66` |

- 配套标准运动参数：入场缓动 `cubic-bezier(0.16, 1, 0.3, 1)`，出场 `cubic-bezier(0.7, 0, 0.84, 0)`（时长比入场短 `40–50%`），弹出 `cubic-bezier(0.34, 1.56, 0.64, 1)`；蓄力蹲伏 `1.2×0.75`、起跳拉伸 `0.85×1.28`、落地挤压 `1.25×0.75`；次级配件滞后（手臂 `4` 帧，尾巴/领结 `6` 帧）。

### 5. `0 .. N-1` 无缝循环边界与多通道无盘流式导出

1. **半开区间 `[0, N)`**：`8 s @ 60 fps` 只渲染帧索引 `0 .. 479`，**严禁渲染第 `480` 帧**（因 `frame[N] === frame[0]` 会在循环衔接处制造可见卡顿）；上线前校验 `|frame[N-1] - frame[0]|` 小于单帧最大步长。若输出 X Article GIF，必须同时压在 4 重硬顶之下：`<= 15 MB`、`<= 1280×1080`、`<= 350` 帧、且总像素 `W × H × frames <= 300,000,000`。
2. **Headless GPU 与子帧快门运动模糊**：Chromium 启用原生 GPU（macOS `--use-angle=metal`、Windows `--use-angle=d3d11`、`--enable-gpu --ignore-gpu-blocklist`）；对快速镜头以 `0.45` 快门角渲染 `8–32` 个子帧并求像素均值。
3. **三条零磁盘中间帧直写 FFmpeg 通道**：
   - **通道 A（Playwright/CDP → `image2pipe`）**：单进程管道写入 PNG，或采用 `heygen-com/hyperframes@7c217d9` 的多 Chrome 进程交错步长 + `O(workerCount)` 内存窗口 `FrameReorderBuffer` + `HeadlessExperimental.beginFrame` `hasDamage` 静态帧复用（`screenshotService.ts#L147-L206`、`streamingEncoder.ts#L91-L350`）；抓透明通道 PNG 时务必禁用 `optimizeForSpeed` 以防 Alpha 塌陷为二值蒙版（`screenshotService.ts#L236-L241`）。
   - **通道 B（Canvas 2D → `rawvideo`）**：参考 `motion-canvas/motion-canvas@7b91435`，从 `getImageData` 取 RGBA 字节流经受背压控制的通道（`EXPORT_FRAME_LIMIT = 256`）推送至 `-f rawvideo -pix_fmt rgba` FFmpeg 进程，免除逐帧 PNG 编解码耗时（`FFmpegExporterClient.ts#L113-L132`）。
   - **通道 C（共享内存帧池 + Rust 解码代理）**：大规模 React 视频选用 `remotion-dev/remotion@53975c8` 的 `Page.remotionCreateFramePool` + `remotionshm` 解复用器与 `/proxy?src=...&time=...` 离线解码服务（`remotion-shared-memory.ts#L85-L160`、`offthread-video-server.ts#L49-L229`）。
4. **封装与流式输出**：可随机寻址落盘 MP4 统一追加 `-movflags +faststart`，由 `FFmpeg/FFmpeg@94cafa1` `compute_moov_size` 两轮试算处理 `moov` 前移后 `4 GiB` 临界点 `stco -> co64` 溢出（`libavformat/movenc.c#L9536-L9589`）；若输出到不可 seek 的 `stdout` 管道则改用 `frag_keyframe+empty_moov`（`movenc.c#L9492-L9500`）。

### 6. 在自有视频管线中的落地映射

- **Remotion 管线（`remotion-explainer-video`）**：将 `useCurrentFrame` 下沉到最小叶子组件；用 `random(seed)` 替代 `Math.random`；为异步资源/字体/地图挂 `delayRender`；Colab L4 分片渲染依赖纯函数无状态保证切片零接缝误差。
- **Opuscar / HTML-to-Video 管线（`opuscar-explainer-video`）**：以 `cues.json` 对齐 `timing.json` 主时钟规则与 `+1` 帧拟音滞后；`prender.mjs` 多进程渲染前注入 `VIRTUAL_TIME_SHIM` 风格的时钟/随机冻结与 `window.renderAt(t)` 协议，并用 `FrameReorderBuffer` + `image2pipe` 替代全量磁盘序列帧。
- **Canvas / p5.js / Three.js 管线（`yiji-motion-video`、`code-rendered-film`）**：全量运动与弹簧采用闭式 `f(t)`；手绘风格引入 `rough` 固定种子或 `boilFps=6`；遵循 `0..N-1` 循环与 8–32 子帧快门平均。

### 7. 帧契约自检、续渲、单一真源与 Blender 帧级剪辑（2026-11-27 增补）

- **`draw(t)` / `seek(t)` 纯函数契约**：`kiselas/every-frame-is-code@603357f` 要求页面暴露 `window.__meta={W,H,FPS,DURATION}`、`window.__draw(t)`、`window.__ready`（可选 `__renderAudio` 返回 OfflineAudioContext WAV），`?render` 时停 rAF（`01-pipeline.md#L11-L85`、`render/render.mjs#L76-L190`）；`sarpstar/cinecode@c8a3e75` 的页侧四接口为 `READY/renderFrame/captureFrame/renderAudio`；Remotion 内嵌 GSAP 用 `paused` timeline + 第二个 `useLayoutEffect` 执行 `tl.seek(frame / fps)`（`berlinify/motion-lab@06daab8` `src/remotion/GsapTitle.tsx#L5-L38`）。
- **CDP `--verify` 确定性回归**：cinecode `scripts/capture.mjs` 先渲第 `k` 帧 → 再渲第 `0` 帧 → 再渲第 `k` 帧，两次第 `k` 帧 SHA 不一致即 exit 1 并提示查帧间状态 / `Date` / `Math.random`（`#L153-L163`）；成片前 `make.py` 强制先跑一遍（`scripts/make.py#L1475-L1647`）。这是第 1 节 Seek Check 不变量的低成本可执行版。
- **内容哈希续渲与原子帧**：stamp = 页面 + params + 实际加载本地文件的内容哈希，变了才清旧帧；帧先写 `.part` 再 rename（`capture.mjs#L186-L198`、`#L245-L247`）。注意 CDN 远程依赖变化不触发失效，需手动 `--fresh`（`capture.mjs#L29-L30`）。多 Chrome 按 `k % n === w` 交错取帧，重排缓冲最多领先 `4n` 帧（`#L200-L250`）。
- **只渲 EDL 用到的帧 + GPU 文件锁**：`Leonxlnx/escapement@02cf7a4` `tools/render_queue.py#L16-L26` 按 EDL 入出点加 handle（软转场 6 帧 / 硬切 2 帧）只渲需要的帧并跳过已存在 PNG；`tools/rb.py` 以 `O_CREAT|O_EXCL` 槽位文件 `MAX_SLOTS = 1` 做全局 GPU 锁（`#L18`、`#L60-L66`），带 pid 校验、陈旧回收、`.want` 公平让步与渲染超时看门狗，且**按帧持锁**，交互测试不被长渲染饿死。
- **单一真源驱动画面、配乐、版式与总帧数**：`mylxsw/cinematic-video-skill@0fbcccc` 的 `timeline.json`（`fps/bpm/scenes[{id,dur,level,card,impact}]`）同时被 Remotion 场景与种子 numpy 配乐（`default_rng(11)`，整小节切镜，level 0–8 递进）读取（`template/video/src/timeline.json#L1-L13`、`template/tools/music.py#L8-L14`）；`sub-level/marketing-videos@696073f` 的 `SCENE` 表求和得 `TOTAL_FRAMES` / `SCENE_START`（“ALWAYS computed, never hardcoded”，`src/tokens.ts#L58-L77`），16:9 / 9:16 与明暗主题经 React Context 单树多版（`src/Root.tsx#L36-L119`），并以 `--scale=2` + Lanczos 超采样交付（`scripts/render-supersampled.sh#L1-L84`）。
- **EDL 定长拟合器**：motion-lab `video-highlights/scripts/plan.ts` 四级降级命中精确目标时长：照片先伸缩 → 视频裁 / 延 → 按 `priority` 丢片 → 素材不足即报错退出（详见 [berlinify/motion-lab](../repos/berlinify__motion-lab.md)）。
- **无头 Blender Python 成片管线**：escapement 全部模型 / 材质 / 灯光 / 相机由 `bmesh` + 节点构建器生成，帧契约三层：`shotlist.json`（局部帧从 1 起 + 两侧 6 帧 handles，`tools/make_shotlist.py#L1-L42`）→ `edl.json`（入出点 / 转场 / grade）→ `cues.json`（相对镜头起点，120 BPM / 12f 网格，`make_cues.py#L1-L27`）；`tools/edit.py` 用 numpy 做逐输出帧 `(clip, src_frame)` 展开、luma / diag 转场与 `seed=k` 逐帧颗粒（`#L262-L300`），`rgb48le → FFV1` 无损中间件再出 x264；`tools/assemble.py#L27-L42` 用 `ffprobe -count_packets` 断言每段帧数等于 EDL。

## 反模式与常见踩坑

- **并行 Worker 打碎顺序物理**：`every-frame-is-code` 文档称 render 模式按帧序推进、固定 `dt` 物理可行（`01-pipeline.md#L101-L105`），但 `render.mjs` 默认多 worker 从块中间起渲（`#L111-L118`），有状态模拟必然分叉；要么单 worker，要么改闭式解。
- **静默吞掉字体加载失败**：`every-frame-is-code` `runtime/film.js#L712` 字体失败仍置 `__ready = true`，成片悄悄回退字体；`__ready` 只能在 `document.fonts.check` 通过后置位，失败应 fail-fast。
- **SFX 生成用 `Math.random`**：`vibegameengine/video-motion-craft@c17ab30` 规则 #11 禁随机，自带 `gen-sfx.mjs#L45` 的噪声与初相位仍用 `Math.random`，音频侧不可复现——确定性约束必须覆盖音频生成脚本，而非只覆盖画面。
- **跨帧积分状态漂移**：在粒子、弹簧或摄像机中写 `pos += vel * dt`，在实时预览或并发 Tab 跳帧渲染时必现落地高度与顺序渲染不一致。
- **HTML/CSS/R3F 暗渡陈仓**：在 Remotion 或并发无头帧渲染中使用 CSS `transition` / `@keyframes`、Tailwind `animate-*` 或 R3F `useFrame`，多 Tab 跳帧抓取直接卡在首帧或闪烁。
- **渲染第 `N` 帧或遗漏 `OutputPass`**：循环视频多渲第 `N` 帧造成肉眼停顿；Three.js 开启 `EffectComposer` 却忘加 `OutputPass` 导致失去色调映射与 sRGB 转码而全片发灰/过曝。
- **盲目混用并发与共享浏览池**：多 Worker 并行渲染时共用同一浏览器进程会导致 `BeginFrame` 与内存池崩溃（参考 `hyperframes` `shouldDisableBrowserPoolForParallelWorker`）。

## 溯源（文章与源码锚点）

- 文章拆解：[2026-11-26-fable-5-2-motion-playbook](../articles/2026-11-26-fable-5-2-motion-playbook.md) · [2026-11-26-flxrnc-15-animation-repos](../articles/2026-11-26-flxrnc-15-animation-repos.md)
- 源码实例：[`remotion-dev/remotion@53975c8`](../repos/remotion-dev__remotion.md) · [`heygen-com/hyperframes@7c217d9`](../repos/heygen-com__hyperframes.md) · [`motion-canvas/motion-canvas@7b91435`](../repos/motion-canvas__motion-canvas.md) · [`mrdoob/three.js@940edbc`](../repos/mrdoob__three.js.md) · [`JDhruv14/line-art-animation@c43d698`](../repos/JDhruv14__line-art-animation.md) · [`finktheartist/sakuga-vfx@c3dabb1`](../repos/finktheartist__sakuga-vfx.md) · [`rough-stuff/rough@56a2762`](../repos/rough-stuff__rough.md) · [`Forward-Future/scarlet@fcb077e`](../repos/Forward-Future__scarlet.md) · [`FFmpeg/FFmpeg@94cafa1`](../repos/FFmpeg__FFmpeg.md)
- 2026-11-27 增补：[2026-11-27-theozguratillay-8-code-video-repos](../articles/2026-11-27-theozguratillay-8-code-video-repos.md) · [`sarpstar/cinecode@c8a3e75`](../repos/sarpstar__cinecode.md) · [`kiselas/every-frame-is-code@603357f`](../repos/kiselas__every-frame-is-code.md) · [`mylxsw/cinematic-video-skill@0fbcccc`](../repos/mylxsw__cinematic-video-skill.md) · [`sub-level/marketing-videos@696073f`](../repos/sub-level__marketing-videos.md) · [`berlinify/motion-lab@06daab8`](../repos/berlinify__motion-lab.md) · [`Leonxlnx/escapement@02cf7a4`](../repos/Leonxlnx__escapement.md) · [`vibegameengine/video-motion-craft@c17ab30`](../repos/vibegameengine__video-motion-craft.md)
- 相关模式：[verified-agent-swarm-harness-and-model-casting](verified-agent-swarm-harness-and-model-casting.md)（`window.seek(t)` 动效片 swarm 的异模型 verifier 数值门：时长 ±0.2s / 落拍 / 色板白名单 / 峰值 < −1 dBFS）
- 2026-11-28 增补：[papercraft-threejs-diorama-film-and-webcodecs-capture](papercraft-threejs-diorama-film-and-webcodecs-capture.md)（`__papercraft.step` 固定时钟 + 页内 WebCodecs H.264 + 帧 0 色块校准，替代逐帧 PNG 截图；源码 [`xikhar/papercraft@30e9aaf`](../repos/xikhar__papercraft.md)）

## Cross-Referenced Specimens

- [A-001 · The Fable 5.2 Motion Playbook：从单条提示词到成片的确定性动效工程手册](https://oumuatown.com/articles/2026-11-26-fable-5-2-motion-playbook.md) — 用纯帧函数与节拍主时钟根除代码动效渲染漂移
- [A-002 · 15 个动效与视频工程开源仓库全景清单（附 Fable 5.2 实战管线）](https://oumuatown.com/articles/2026-11-26-flxrnc-15-animation-repos.md) — 十五个动效与视频工程开源仓串起代码出片全链路
- [R-016 · remotion-dev/remotion](https://oumuatown.com/repos/remotion-dev__remotion.md) — React树即纯函数视频轴，靠共享内存池与Rust合成
- [R-178 · heygen-com/hyperframes](https://oumuatown.com/repos/heygen-com__hyperframes.md) — 虚拟时间垫片配 CDP 帧捕获，稳把网页动效渲染成视频
- [R-011 · motion-canvas/motion-canvas](https://oumuatown.com/repos/motion-canvas__motion-canvas.md) — TS生成器协程调度惰性信号链，将命令式动画编成逐帧流
- [R-012 · mrdoob/three.js](https://oumuatown.com/repos/mrdoob__three.js.md) — WebGL2/WebGPU双后端，混合器稳跑确定性成片
- [R-009 · JDhruv14/line-art-animation](https://oumuatown.com/repos/JDhruv14__line-art-animation.md) — 零依赖TS手绘动画技能：双边留白描边与步态逆解去塑料感
- [R-003 · finktheartist/sakuga-vfx](https://oumuatown.com/repos/finktheartist__sakuga-vfx.md) — 全局单画布与弹簧挤压形变，零依赖实现动漫作画打击感
- [R-018 · rough-stuff/rough](https://oumuatown.com/repos/rough-stuff__rough.md) — OpSet中间表示配双笔抖动，同一扫线填充双出矢量与位图
- [R-004 · Forward-Future/scarlet](https://oumuatown.com/repos/Forward-Future__scarlet.md) — 源时间锚定Rebase配分段缓存，驱动MCP桌面AI剪辑
- [R-038 · FFmpeg/FFmpeg](https://oumuatown.com/repos/FFmpeg__FFmpeg.md) — 音视频管线基石：覆盖响度审计、静帧检测与无鬼影运动模糊
- [A-018 · 不烧视频额度，用 Claude / Codex 写代码出电影感短片的 8 个 GitHub 仓库](https://oumuatown.com/articles/2026-11-27-theozguratillay-8-code-video-repos.md) — 源码核验八个代码出片仓：全系纯代码渲染且四处宣发注水
- [R-078 · sarpstar/cinecode](https://oumuatown.com/repos/sarpstar__cinecode.md) — Hooks守六门配断点续渲，多开浏览器交错出母带
- [R-057 · kiselas/every-frame-is-code](https://oumuatown.com/repos/kiselas__every-frame-is-code.md) — 纯函数draw(t)驱动多开截帧，自带节拍图与合成配乐
- [R-063 · mylxsw/cinematic-video-skill](https://oumuatown.com/repos/mylxsw__cinematic-video-skill.md) — 单真源同步画面与配乐，探针零错才渲染且无旁白
- [R-084 · sub-level/marketing-videos](https://oumuatown.com/repos/sub-level__marketing-videos.md) — 单树出多版且AI静帧先审，但仓内实无音频与生成代码
- [R-029 · berlinify/motion-lab](https://oumuatown.com/repos/berlinify__motion-lab.md) — 可复用GSAP寻帧与EDL定长拟合，但宣传的3D运镜名不副实
- [R-061 · Leonxlnx/escapement](https://oumuatown.com/repos/Leonxlnx__escapement.md) — 全程序化Blender短片管线，强绑Windows且缺音频
- [R-093 · vibegameengine/video-motion-craft](https://oumuatown.com/repos/vibegameengine__video-motion-craft.md) — 四仓拼装双路由视频技能，实仅片段脚本且缺TTS
- [P-018 · 可核验多智能体 Swarm 编制、异模型 Verifier 与选角成本纪律模式（Verified Agent-Swarm Harness & Model Casting）](https://oumuatown.com/patterns/verified-agent-swarm-harness-and-model-casting.md) — 三席选角、三段式委托与异模型全新上下文路径行号签收
- [P-024 · 纸艺立体书 three.js 微缩短片与页内 WebCodecs 确定性出片模式（Papercraft three.js Diorama Film & WebCodecs Capture）](https://oumuatown.com/patterns/papercraft-threejs-diorama-film-and-webcodecs-capture.md) — 纸艺质感配页内 WebCodecs 出片，告别慢截帧偏色
- [R-123 · xikhar/papercraft](https://oumuatown.com/repos/xikhar__papercraft.md) — 立体书纸艺Three.js套件，固定时钟编码直出视频
- [P-005 · 程序化三维世界构建、浏览器导播台与光追热插拔成片管线（Procedural World, Camera Rig & Cycles Hot-Swap Pipeline）](https://oumuatown.com/patterns/procedural-world-and-camera-rig-pipeline.md) — 纯函数共享演出表与无锁弧长导播台贯通 Web 与光追双轨
- [P-006 · 全栈 AI 游戏工作台、跨宿主技能分发与多端商业化打包管线（Agentic Game Studio, Cross-Host Skill Installer & Multi-Platform Monetization）](https://oumuatown.com/patterns/agentic-game-studio-and-multiplatform-monetization.md) — 模板混改、79 宿主锁文件与双端小游戏商业化管线
- [P-010 · 立体剖面 3D 微缩沙盘、Metal ANGLE 安全着色器、单文件离线交付与双盲 A/B 评测台模式（Cutaway 3D Diorama, Metal WebGL2 Safety & A/B Arena）](https://oumuatown.com/patterns/cutaway-3d-diorama-metal-webgl-and-ab-harness.md) — 剖面沙盘 Metal 安全着色器、避让引线与双盲评测台
- [P-013 · Godot 4.7+ 零资产程序化世界、GPU 零回读浅水模拟与切镜安全 2× 运动模糊导出（Godot Procedural World & GPU Simulation）](https://oumuatown.com/patterns/godot-procedural-world-and-gpu-simulation.md) — Godot 零回读浅水计算与切镜安全双帧运动模糊导出
- [P-014 · 手绘像素风格化、参考动效逐帧逆向复刻与多运行时确定性寻帧闭环（Hand-Drawn/Pixel Stylization, Animation Remake & Deterministic Stepping Loop）](https://oumuatown.com/patterns/hand-drawn-pixel-stylization-and-animation-remake-loop.md) — 手绘像素四通道风格化、逆向逐帧复刻与多引擎离线寻帧闭环
- [P-016 · 多智能体互动课堂、个性化导师与教育科技全栈管线（Multi-Agent Interactive Classroom, Adaptive Tutoring & EdTech Pipeline）](https://oumuatown.com/patterns/multi-agent-interactive-classroom-and-edtech-pipeline.md) — 多智能体课堂瘦调度、CJK 零分过滤检索与教育合规门禁
- [P-019 · 零资产程序化建筑重建、多镜头着色器与平面图双向漫游管线（Zero-Asset Procedural Architecture, Multi-Lens Shaders & Plan Walkthrough）](https://oumuatown.com/patterns/zero-asset-procedural-architecture-and-plan-walkthrough.md) — 模数轴网解耦、三镜头着色器与平面图双向配准的零资产漫游
- [P-020 · AI 视频四轨生产、Code2Video 工艺、Blender Previs、Seedance 2.5 UGC 与 Unity/UE 官方插件工程手册](https://oumuatown.com/patterns/ai-video-previs-code2video-and-ugc-production-playbook.md) — 贯通四轨视频产线、预演锁镜与引擎六闸门验收闭环
- [P-021 · 代码复刻 IDE 数字孪生与富情绪“抑→顿→扬”长视频解说模式（Code-Rendered IDE Twin & Expressive Explainer Voice）](https://oumuatown.com/patterns/code-rendered-ide-twin-and-expressive-explainer-voice.md) — 代码数字孪生界面配「抑顿扬」低基线韵律打造技术长解说
- [P-028 · 音频驱动逆向抛物线弹珠下落视频合成模式（Audio-Synced Inverse-Physics Marble Drop）](https://oumuatown.com/patterns/audio-synced-inverse-physics-marble-drop-video.md) — 逆向弹道求解与视口避障批量生成零穿模音乐弹珠片
- [P-034 · 代码艺术风格配方、参数化解说语法与全链路防 AI-Slop 门禁体系（Artistic Style Recipes, Explainer Grammars & Anti-Slop QA）](https://oumuatown.com/patterns/artistic-code-style-recipes-and-explainer-grammars.md) — 材料与时代风格拆解配参数化语法，叠加像素音画硬门禁
- [R-007 · huangserva/manhattan-free-roam](https://oumuatown.com/repos/huangserva__manhattan-free-roam.md) — 前端实时取景直出烘焙，零依赖共享数学模块对齐光追成片
- [R-024 · andrewalumkal/VisualLearning.Skill](https://oumuatown.com/repos/andrewalumkal__VisualLearning.Skill.md) — 零构建单文件SVG交互图解技能，配溯源提案与子代理盲审
- [R-039 · finiking/model-lab](https://oumuatown.com/repos/finiking__model-lab.md) — 单文件 3D 双盲评测台，拆解重庆沙盘零外链与渲染防坑
- [R-043 · godotengine/godot](https://oumuatown.com/repos/godotengine__godot.md) — 靠零回读计算着色与固定帧录制，筑牢程序化 3D 短片底座
- [R-046 · greensock/GSAP](https://oumuatown.com/repos/greensock__GSAP.md) — 双向链表场景树配时间轴随机定位，稳撑交互动效与逐帧录屏
- [R-048 · HarleyCoops/Math-To-Manim](https://oumuatown.com/repos/HarleyCoops__Math-To-Manim.md) — 反向知识树创意亮眼，但九套代码孤岛堆叠且有静默降级坑
- [R-062 · motiondivision/motion](https://oumuatown.com/repos/motiondivision__motion.md) — WAAPI卸载配FLiP投影，离线逐帧踩双时钟陷阱
- [R-065 · nexu-io/opengame](https://oumuatown.com/repos/nexu-io__opengame.md) — MCP驱动无头试玩与9网可玩广告打包，打通小游戏生产
- [R-066 · nexu-io/openmotion](https://oumuatown.com/repos/nexu-io__openmotion.md) — 隔离渲染配纯内存时间轴与便携契约，专攻参考视频复刻
- [R-067 · NiazMorshed2007/reanimate](https://oumuatown.com/repos/NiazMorshed2007__reanimate.md) — 虚拟时钟配引擎场景探针，像素级克隆WebGL网页动效
- [R-071 · patch-gg/pixelfx](https://oumuatown.com/repos/patch-gg__pixelfx.md) — 零依赖软光栅配抖动出244像素特效，带自检闭环
- [R-073 · pmndrs/react-three-fiber](https://oumuatown.com/repos/pmndrs__react-three-fiber.md) — React协调器接管Three.js，支持按需步进离线渲染
- [R-076 · remotion-dev/claude-code-plugin](https://oumuatown.com/repos/remotion-dev__claude-code-plugin.md) — 双清单文本化封装14项视频技能，过审零脚本插件市场
- [R-085 · Tejashmakwana/motionmaxxing](https://oumuatown.com/repos/Tejashmakwana__motionmaxxing.md) — 拆解53条商业样片提炼12条曲线，配寻帧安全GSAP硬门禁
- [R-087 · theatre-js/theatre](https://oumuatown.com/repos/theatre-js__theatre.md) — 细粒度信号图配四层合并，精确解耦动画运行时与可视化编辑器
- [A-006 · Gemini 4 Neon 八步搭建 AI Agent 团队——Orchestrator 规划/执行配对、.agents/ 团队文件、异模型 Verifier 与 ADK 2.0 工作流](https://oumuatown.com/articles/2026-11-27-0xmovez-gemini-neon-agent-swarm-harness.md) — 提示词工程让位于编制：规划执行分席与异模型验收
- [A-014 · Gemini 4 Carbon × Godot 4.7 零 3D 模型代码生成京都苔庭——七段可执行物理数学 Agent 规格说明书全解](https://oumuatown.com/articles/2026-11-27-kanaworks-godot-moss-garden-procedural-spec.md) — 七段物理数学规格驱动 Godot 零资产浅水与苔庭渲染
- [A-015 · 重庆 8D 山城雨夜微缩沙盘可执行 Prompt 解剖与 GPT-6.2 Astra vs Gemini 4 Neon 源码级实测横评](https://oumuatown.com/articles/2026-11-27-leaf-sanren-finiyang-chongqing-8d-diorama.md) — 微缩沙盘 Metal 护栏与双模型源码级实测横评
- [A-017 · 6 个 AI+儿童教育开源项目与 Skill 盘点拆解——高校旗舰平台与个人轻量原型的工程成熟度断层及合规红线](https://oumuatown.com/articles/2026-11-27-rachidsettas-6-ai-education-oss-repos.md) — 实测六款 AI 教育开源仓的工程成熟度断层与合规红线
- [A-028 · 浙大猫学长：《一句话动效实测 Gemini 4 Neon》4 分 15 秒长视频深度解剖——代码复刻 IDE 数字孪生、抑扬顿挫配音韵律与取舍清单](https://oumuatown.com/articles/2026-11-28-zjucat-vibemotion-gemini4-neon-explainer-anatomy.md) — 用代码复刻 IDE 数字孪生与高跨度配音韵律造解说长片
- [A-033 · Soutine × Gorden Sun（大肥鱼讲AI）：4 分 32 秒 3D 音乐弹珠下落视频深度解剖——逆向弹道卡点、歌词语义弹板与同款制作方案](https://oumuatown.com/articles/2026-11-30-soutine-gorden-sun-music-marble-drop.md) — 逆向抛物线卡点与歌词语义弹板造一镜到底音乐弹珠片
- [A-038 · huashu-art-motion（36+17 风格代码动画引擎）与 15 个动效/视频开源仓生态拆解](https://oumuatown.com/articles/2026-12-03-voxyz-huashu-art-motion-and-15-motion-repos.md) — 36画风9语法配三道物理门禁，15仓串起AI动效生态
