ClearFrame engine
HTML/CSS/SVG/Canvas animated by one paused GSAP timeline. The renderer opens the page in headless Chrome, calls __CF.seek(t) for every frame, captures it and pipes it to ffmpeg. The same input always gives the same frames.
Setup
git clone https://github.com/brandonbryant12/clearframe && cd clearframe && npm install # Node ≥ 20, ffmpeg on PATH
npm link # optional: puts `clearframe` on your PATH (otherwise: node engine/cli.mjs …)
Installed as a Claude Code plugin? Run npm install once in ${CLAUDE_PLUGIN_ROOT} and invoke node ${CLAUDE_PLUGIN_ROOT}/engine/cli.mjs.
Project layout
my-video/
storyboard.json # script, beats, voice, music, assets, sources ← the source of truth
STYLE.md # optional: rules shared by every scene builder
data.json # optional: figures (available as ctx.data)
index.html # optional: global layers (omit it and the default composition is used)
scenes/*.js # optional: custom scene modules (parallel-friendly); most beats use library blocks instead
assets/vo|music|img|clips|sfx/ # generated or supplied media (+ .json metadata)
build/ # timing.json, sheet.png, stills, captions, renders
storyboard.json
{
"title": "…", "format": { "preset": "landscape" | "vertical" | "square" | "portrait", "fps": 30 },
"theme": "paper", // paper | ink | ember | editorial | slate | signal
"backdrop": "dots", // dots | grid | ruled | topo | aurora | none (default composition)
"chrome": "auto", "captions": "auto", "transition": "auto", "sfx": false, "grain": true, "vignette": true,
"budget": 1.0, // USD hard cap for paid generation
"voice": { "model": "gemini-3.8-flash-tts", "voice": "Charon", "style": "calm, measured", "wpm": 150 },
"music": { "model": "lyria-3.5", "prompt": "…", "bpm": 80, "key": "D major", "volume": 0.2, "arc": { "<chapter>": "…" } },
"pacing": { "lead": 0.25, "tail": 0.6, "minBeat": 1.6 },
"beats": [
{ "id": "kpis", "chapter": "Headline", "block": "kpis", "props": { "items": [ … ] }, "vo": "…" }, // a library block
{ "id": "hook", "chapter": "The forecast", "scene": "scenes/forecast.js", // or your own scene module
"vo": "Seventy percent. <short pause> It sounds like a sure thing.",
"visual": "What the eye sees when the words land.",
"lead": 0.5, "tail": 0.5, "hold": 0, "duration": null, "style": null,
"sfx": [{ "src": "assets/sfx/tick.wav", "at": "word:seventy", "volume": 0.5 }] }
],
"assets": [
{ "id": "paper-texture", "kind": "image", "prompt": "…", "size": "2K" },
{ "id": "city-dawn", "kind": "clip", "prompt": "…", "seconds": 4, "from": "paper-texture" }
],
"sources": [{ "claim": "…", "source": "…", "asOf": "2026-09" }]
}
Beat length = max(minBeat, lead + voice + tail + hold), or a fixed duration. A negative lead gives a J-cut, where the voice starts before the picture. tail defaults to the block's own recommended hold (meta.tail, 0.9–1.8 s), otherwise pacing.tail. Per beat, "transition" overrides the cut into it. music: false disables music. The JSON Schema is in schema/storyboard.schema.json.
Blocks and storyboard-only projects
"block": "<name>" plus "props" mounts a library scene from engine/runtime/blocks/. There are 33 of them: charts, numbers, diagrams, UI, text and cards. The catalogue is in the clearframe-library skill, clearframe blocks, and docs/media/blocks.jpg. With no index.html, the engine serves a default composition: blocks, then backdrop, grain, vignette, chrome ('auto'), captions ('auto', on for 9:16) and automatic transitions ('auto': rise across chapters, fade within). A project can be only storyboard.json.
index.html
Only needed for custom global layers. Start from engine/runtime/default.html:
<link rel="stylesheet" href="/_cf/cf.css">
<div id="stage"><div id="scenes"></div></div>
<script src="/_cf/all.js"></script> <!-- GSAP + SplitText + CustomEase + MotionPath + runtime + kit + kit+ -->
<script>
CF.compose((ctx) => {
ctx.kit.look(ctx); // the default look (backdrop, grain, chrome, captions, transitions)…
// …or do it by hand: kit.backdrop(stage, 'topo'); kit.grain(stage); kit.transition('fade', A, B, 'next');
});
</script>
Fonts, GSAP, icons and the runtime are served locally by the engine from node_modules, so renders never touch a CDN. The individual files (/_cf/vendor/gsap/*.js, /_cf/cf.js, /_cf/cf-kit.js, /_cf/cf-kit-plus.js) still work.
Scene modules (scenes/*.js)
A beat with "scene": "scenes/x.js" gets a <section class="cf-scene" data-beat="<id>">. It is visible only during that beat; set el.dataset.until = '<laterBeatId>' to span beats.
export const css = `.fc .big { font-family: var(--cf-display); font-size: calc(440px * var(--u)); }`;
export const html = (props, ctx) => `<div class="fc"><div class="big">70%</div><div class="sub">chance …</div></div>`; // or a string
export default async function ({ el, b, beat, tl, kit, data, rand, time, stage, timing, props, cue, sound, format }) {
el.dataset.until = 'flip'; // keep this scene through the "flip" beat
const flip = beat('flip');
kit.reveal(el.querySelector('.big'), b.say('seventy') - 0.15, { by: 'chars', mask: true, ease: kit.tokens.ease.snap });
tl.to(el.querySelector('.big'), { y: -250, scale: 0.6, duration: 0.9, ease: 'power3.inOut' }, flip.at(0.1));
}
Scene modules and blocks share one mount path and the same ctx, so you can fork a block: copy engine/runtime/blocks/<name>.js into scenes/, change ./_lib.js to /_cf/blocks/_lib.js, and point a beat's scene at it. props comes from the beat's props; cue(spec, fallback) turns a spoken word or seconds into a time; sound(name, t) emits a sound cue when sfx is on. Compose blocks inside a scene with await CF.mount('stat', someEl, { value: 42 }, b). Scene modules build in beat order, before the global compose callback. Declarative scenes also work: put <section data-beat="id" data-until="other" data-in="-0.2" data-out="0.4"> straight into index.html.
Runtime API
|
|
b.start, b.end, b.dur |
beat bounds (s) |
b.at(s) / b.before(s) / b.p(f) |
s after start / s before end / fraction f of the beat |
b.say('word', { nth, edge: 'start'|'end', offset }) |
absolute time the narrator says it (fuzzy, punctuation-insensitive; multi-word ok) |
b.voStart / b.voEnd / b.vo.words |
narration timing |
beat(id) |
another beat |
time(spec) |
"id", "id+0.4", "id@0.5", "id:end" → seconds (all kit at args accept these) |
tl |
the master timeline. Every tween goes on it. |
CF.onFrame((t, frame) => …) |
per-frame drawing (canvas, derived text) |
rand(seed) |
seeded PRNG: .range .int .pick .shuffle |
data |
parsed data.json or null |
CF.mount(name, el, props, beat) |
mount a library block anywhere (returns the element) |
CF.sfx(name, t, { volume }) |
sound cue: tick tock pop click type whoosh chime thud rise (synthesized) or a project file path. Mixed in at render; played in preview |
format / look |
'landscape'|'vertical'|'square' / the storyboard look settings |
Preview URL params: ?t=12.5 jumps to a time. Keys: space play, ←/→ frame, shift+←/→ 1 s, [ ] beats, S safe areas, M mute.
Determinism rules (break them and frames flicker or differ between workers)
- Every tween lives on
tl. No gsap.to() outside it, no setTimeout, no requestAnimationFrame loops, no Date.now(), no Math.random() (use rand(seed)). check warns about stray tweens.
- Never tween a property that an
onFrame function also writes. Wrap it in a parent element and tween the wrapper. Prefer fromTo (with immediateRender: false for later tweens) when a start value could be ambiguous.
- Derived drawing (canvas, counters, chart tips) belongs in
CF.onFrame, reading tweened proxies.
<video data-start="beatId+0.2" data-offset="0" muted> for footage. The runtime seeks it per frame. Audio comes only from the mix, never from page media.
- CSS
@keyframes are allowed for ambient loops; the runtime pins them to the playhead.
- Fonts are loaded before build, so splitting and measuring are safe inside scene modules.
- Tag ambient tweens (camera drifts) with
data: 'cf-ambient'. The runtime flags any other animation still running after its beat (animation runs Xs past the beat), because that payoff would be cut. kit.drift and kit.transition tag themselves.
Kit (full API in references/kit.md)
- Text:
reveal, exit, enter, hit, mark, counter, odometer, scramble, type, fit, split, md, esc, spoken
- Scene and camera:
drift, transition, autoTransitions, camera (zoomTo / reset / push), spotlight, cursor, rectIn
- Look:
look, backdrop (dots / grid / ruled / topo / aurora), grain, vignette, gridlines, chrome, marquee, captions
- Data:
lineChart (dash), bars, waffle, donut, meter, milestones, steps, chip, draw, arrow, niceTicks, fmt, color
- Icons:
await icon(parent, 'shield-check', { size }), drawIcon(svg, at) (Lucide; search with clearframe icons)
- Cues:
cueFor(b), spread(b, i, n), sequence(els, b, cues)
- Credibility:
source, footnote
- Tokens:
kit.tokens
CLI
| Command |
What it does |
clearframe doctor |
check ffmpeg (+ required filters/encoders), headless Chrome, fonts, icons, draft voice, API key |
clearframe new <dir> [--recipe <name> | --template explainer|vertical] |
scaffold (recipes are block-only storyboards) |
clearframe recipes · clearframe blocks [name] [--json|--md] · clearframe icons <query> |
discover recipes, blocks (props plus an example beat), and icon names |
clearframe gallery [dir] [--vertical] |
render every block into a catalogue grid PNG |
clearframe preview [dir] |
live preview with synced voice/music and a beat scrubber (auto-reload) |
clearframe plan [dir] |
the paid calls needed, what's cached, and their cost |
clearframe voice [dir] [--draft] [--only a,b] [--force] |
TTS per beat (cached by hash); trims silence; aligns words |
clearframe music [dir] [--draft] |
Lyria bed shaped to the chapters, or a free synthesized pad |
clearframe images [dir] / clips [dir] |
declared image / footage assets |
clearframe timing [dir] |
beat table with pace (wpm) |
clearframe sheet [dir] [--per 3] [--grid 4] |
contact sheet PNG. Read it. --grid = one frame per beat |
clearframe still [dir] --beat id [--pos 0.6] / --at 12.5 |
full-res frame |
clearframe check [dir] |
QA: frame edges, safe areas, overflow, tiny text, overlaps, word counts, pace, stillness, sources, missing files, stray tweens |
clearframe captions [dir] |
SRT + VTT |
clearframe render [dir] [--draft] [--lossless] [--workers n] [--from s --to s] |
MP4 (H.264 BT.709, AAC, −14 LUFS). Block sound cues are mixed in |
Debugging
- A build error shows as a red overlay in preview. The renderer prints it and stops.
- A
say() miss logs narration has no word "…". Match the text as written in vo ("seventy", not "70").
- Something is invisible? Check the scene's beat window,
data-until, a from() tween that never ends, or an opacity tween that fights an onFrame function.
- Timing feels off? Run
clearframe timing. The rows marked est have no recorded voice yet.
- Slow renders:
--draft is half-resolution JPEG; --workers defaults to half your CPU cores (max 6).
1---2name: clearframe-engine-23description: Technical reference for building ClearFrame videos — project layout, storyboard.json schema, the composition + scene-module contract, the CF runtime (compose, beats, say(), time specs, onFrame, determinism rules), the CF.kit motion/data components, and the clearframe CLI (preview, voice, music, sheet, check, render). Use when writing or debugging storyboard.json, index.html or scenes/*.js, or running the engine.4metadata:5 source: https://skillmd.com/skills/brandonbryant12/clearframe-engine-26---78# ClearFrame engine910HTML/CSS/SVG/Canvas animated by **one paused GSAP timeline**. The renderer opens the page in headless Chrome, calls `__CF.seek(t)` for every frame, captures it and pipes it to ffmpeg. The same input always gives the same frames.1112## Setup1314```bash15git clone https://github.com/brandonbryant12/clearframe && cd clearframe && npm install # Node ≥ 20, ffmpeg on PATH16npm link # optional: puts `clearframe` on your PATH (otherwise: node engine/cli.mjs …)17```18Installed as a Claude Code plugin? Run `npm install` once in `${CLAUDE_PLUGIN_ROOT}` and invoke `node ${CLAUDE_PLUGIN_ROOT}/engine/cli.mjs`.1920## Project layout2122```23my-video/24 storyboard.json # script, beats, voice, music, assets, sources ← the source of truth25 STYLE.md # optional: rules shared by every scene builder26 data.json # optional: figures (available as ctx.data)27 index.html # optional: global layers (omit it and the default composition is used)28 scenes/*.js # optional: custom scene modules (parallel-friendly); most beats use library blocks instead29 assets/vo|music|img|clips|sfx/ # generated or supplied media (+ .json metadata)30 build/ # timing.json, sheet.png, stills, captions, renders31```3233## storyboard.json3435```jsonc36{37 "title": "…", "format": { "preset": "landscape" | "vertical" | "square" | "portrait", "fps": 30 },38 "theme": "paper", // paper | ink | ember | editorial | slate | signal39 "backdrop": "dots", // dots | grid | ruled | topo | aurora | none (default composition)40 "chrome": "auto", "captions": "auto", "transition": "auto", "sfx": false, "grain": true, "vignette": true,41 "budget": 1.0, // USD hard cap for paid generation42 "voice": { "model": "gemini-3.8-flash-tts", "voice": "Charon", "style": "calm, measured", "wpm": 150 },43 "music": { "model": "lyria-3.5", "prompt": "…", "bpm": 80, "key": "D major", "volume": 0.2, "arc": { "<chapter>": "…" } },44 "pacing": { "lead": 0.25, "tail": 0.6, "minBeat": 1.6 },45 "beats": [46 { "id": "kpis", "chapter": "Headline", "block": "kpis", "props": { "items": [ … ] }, "vo": "…" }, // a library block47 { "id": "hook", "chapter": "The forecast", "scene": "scenes/forecast.js", // or your own scene module48 "vo": "Seventy percent. <short pause> It sounds like a sure thing.",49 "visual": "What the eye sees when the words land.",50 "lead": 0.5, "tail": 0.5, "hold": 0, "duration": null, "style": null,51 "sfx": [{ "src": "assets/sfx/tick.wav", "at": "word:seventy", "volume": 0.5 }] }52 ],53 "assets": [54 { "id": "paper-texture", "kind": "image", "prompt": "…", "size": "2K" },55 { "id": "city-dawn", "kind": "clip", "prompt": "…", "seconds": 4, "from": "paper-texture" }56 ],57 "sources": [{ "claim": "…", "source": "…", "asOf": "2026-09" }]58}59```60Beat length = `max(minBeat, lead + voice + tail + hold)`, or a fixed `duration`. A negative `lead` gives a J-cut, where the voice starts before the picture. `tail` defaults to the block's own recommended hold (`meta.tail`, 0.9–1.8 s), otherwise `pacing.tail`. Per beat, `"transition"` overrides the cut into it. `music: false` disables music. The JSON Schema is in `schema/storyboard.schema.json`.6162## Blocks and storyboard-only projects6364`"block": "<name>"` plus `"props"` mounts a library scene from `engine/runtime/blocks/`. There are 33 of them: charts, numbers, diagrams, UI, text and cards. The catalogue is in the `clearframe-library` skill, `clearframe blocks`, and `docs/media/blocks.jpg`. **With no `index.html`, the engine serves a default composition**: blocks, then backdrop, grain, vignette, chrome (`'auto'`), captions (`'auto'`, on for 9:16) and automatic transitions (`'auto'`: rise across chapters, fade within). A project can be only `storyboard.json`.6566## index.html6768Only needed for custom global layers. Start from `engine/runtime/default.html`:6970```html71<link rel="stylesheet" href="/_cf/cf.css">72<div id="stage"><div id="scenes"></div></div>73<script src="/_cf/all.js"></script> <!-- GSAP + SplitText + CustomEase + MotionPath + runtime + kit + kit+ -->74<script>75 CF.compose((ctx) => {76 ctx.kit.look(ctx); // the default look (backdrop, grain, chrome, captions, transitions)…77 // …or do it by hand: kit.backdrop(stage, 'topo'); kit.grain(stage); kit.transition('fade', A, B, 'next');78 });79</script>80```81Fonts, GSAP, icons and the runtime are served locally by the engine from `node_modules`, so renders never touch a CDN. The individual files (`/_cf/vendor/gsap/*.js`, `/_cf/cf.js`, `/_cf/cf-kit.js`, `/_cf/cf-kit-plus.js`) still work.8283## Scene modules (`scenes/*.js`)8485A beat with `"scene": "scenes/x.js"` gets a `<section class="cf-scene" data-beat="<id>">`. It is visible only during that beat; set `el.dataset.until = '<laterBeatId>'` to span beats.8687```js88export const css = `.fc .big { font-family: var(--cf-display); font-size: calc(440px * var(--u)); }`;89export const html = (props, ctx) => `<div class="fc"><div class="big">70%</div><div class="sub">chance …</div></div>`; // or a string90export default async function ({ el, b, beat, tl, kit, data, rand, time, stage, timing, props, cue, sound, format }) {91 el.dataset.until = 'flip'; // keep this scene through the "flip" beat92 const flip = beat('flip');93 kit.reveal(el.querySelector('.big'), b.say('seventy') - 0.15, { by: 'chars', mask: true, ease: kit.tokens.ease.snap });94 tl.to(el.querySelector('.big'), { y: -250, scale: 0.6, duration: 0.9, ease: 'power3.inOut' }, flip.at(0.1));95}96```97Scene modules and blocks share one mount path and the same `ctx`, so you can **fork a block**: copy `engine/runtime/blocks/<name>.js` into `scenes/`, change `./_lib.js` to `/_cf/blocks/_lib.js`, and point a beat's `scene` at it. `props` comes from the beat's `props`; `cue(spec, fallback)` turns a spoken word or seconds into a time; `sound(name, t)` emits a sound cue when `sfx` is on. **Compose blocks inside a scene** with `await CF.mount('stat', someEl, { value: 42 }, b)`. Scene modules build in beat order, before the global `compose` callback. Declarative scenes also work: put `<section data-beat="id" data-until="other" data-in="-0.2" data-out="0.4">` straight into `index.html`.9899## Runtime API100101| | |102|---|---|103| `b.start`, `b.end`, `b.dur` | beat bounds (s) |104| `b.at(s)` / `b.before(s)` / `b.p(f)` | `s` after start / `s` before end / fraction `f` of the beat |105| `b.say('word', { nth, edge: 'start'\|'end', offset })` | **absolute time the narrator says it** (fuzzy, punctuation-insensitive; multi-word ok) |106| `b.voStart` / `b.voEnd` / `b.vo.words` | narration timing |107| `beat(id)` | another beat |108| `time(spec)` | `"id"`, `"id+0.4"`, `"id@0.5"`, `"id:end"` → seconds (all kit `at` args accept these) |109| `tl` | the master timeline. **Every tween goes on it.** |110| `CF.onFrame((t, frame) => …)` | per-frame drawing (canvas, derived text) |111| `rand(seed)` | seeded PRNG: `.range .int .pick .shuffle` |112| `data` | parsed `data.json` or `null` |113| `CF.mount(name, el, props, beat)` | mount a library block anywhere (returns the element) |114| `CF.sfx(name, t, { volume })` | sound cue: `tick tock pop click type whoosh chime thud rise` (synthesized) or a project file path. Mixed in at render; played in preview |115| `format` / `look` | `'landscape'\|'vertical'\|'square'` / the storyboard look settings |116117Preview URL params: `?t=12.5` jumps to a time. Keys: space play, ←/→ frame, shift+←/→ 1 s, `[` `]` beats, `S` safe areas, `M` mute.118119## Determinism rules (break them and frames flicker or differ between workers)1201211. **Every tween lives on `tl`.** No `gsap.to()` outside it, no `setTimeout`, no `requestAnimationFrame` loops, no `Date.now()`, no `Math.random()` (use `rand(seed)`). `check` warns about stray tweens.1222. **Never tween a property that an `onFrame` function also writes.** Wrap it in a parent element and tween the wrapper. Prefer `fromTo` (with `immediateRender: false` for later tweens) when a start value could be ambiguous.1233. Derived drawing (canvas, counters, chart tips) belongs in `CF.onFrame`, reading tweened proxies.1244. `<video data-start="beatId+0.2" data-offset="0" muted>` for footage. The runtime seeks it per frame. Audio comes only from the mix, never from page media.1255. CSS `@keyframes` are allowed for ambient loops; the runtime pins them to the playhead.1266. Fonts are loaded before build, so splitting and measuring are safe inside scene modules.1277. Tag ambient tweens (camera drifts) with `data: 'cf-ambient'`. The runtime flags any other animation still running after its beat (`animation runs Xs past the beat`), because that payoff would be cut. `kit.drift` and `kit.transition` tag themselves.128129## Kit (full API in `references/kit.md`)130131- **Text:** `reveal, exit, enter, hit, mark, counter, odometer, scramble, type, fit, split, md, esc, spoken`132- **Scene and camera:** `drift, transition, autoTransitions, camera (zoomTo / reset / push), spotlight, cursor, rectIn`133- **Look:** `look, backdrop (dots / grid / ruled / topo / aurora), grain, vignette, gridlines, chrome, marquee, captions`134- **Data:** `lineChart (dash), bars, waffle, donut, meter, milestones, steps, chip, draw, arrow, niceTicks, fmt, color`135- **Icons:** `await icon(parent, 'shield-check', { size })`, `drawIcon(svg, at)` (Lucide; search with `clearframe icons`)136- **Cues:** `cueFor(b)`, `spread(b, i, n)`, `sequence(els, b, cues)`137- **Credibility:** `source, footnote`138- **Tokens:** `kit.tokens`139140## CLI141142| Command | What it does |143|---|---|144| `clearframe doctor` | check ffmpeg (+ required filters/encoders), headless Chrome, fonts, icons, draft voice, API key |145| `clearframe new <dir> [--recipe <name> \| --template explainer\|vertical]` | scaffold (recipes are block-only storyboards) |146| `clearframe recipes` · `clearframe blocks [name] [--json\|--md]` · `clearframe icons <query>` | discover recipes, blocks (props plus an example beat), and icon names |147| `clearframe gallery [dir] [--vertical]` | render every block into a catalogue grid PNG |148| `clearframe preview [dir]` | live preview with synced voice/music and a beat scrubber (auto-reload) |149| `clearframe plan [dir]` | the paid calls needed, what's cached, and their cost |150| `clearframe voice [dir] [--draft] [--only a,b] [--force]` | TTS per beat (cached by hash); trims silence; aligns words |151| `clearframe music [dir] [--draft]` | Lyria bed shaped to the chapters, or a free synthesized pad |152| `clearframe images [dir]` / `clips [dir]` | declared image / footage assets |153| `clearframe timing [dir]` | beat table with pace (wpm) |154| `clearframe sheet [dir] [--per 3] [--grid 4]` | **contact sheet PNG. Read it.** `--grid` = one frame per beat |155| `clearframe still [dir] --beat id [--pos 0.6]` / `--at 12.5` | full-res frame |156| `clearframe check [dir]` | QA: frame edges, safe areas, overflow, tiny text, overlaps, word counts, pace, stillness, sources, missing files, stray tweens |157| `clearframe captions [dir]` | SRT + VTT |158| `clearframe render [dir] [--draft] [--lossless] [--workers n] [--from s --to s]` | MP4 (H.264 BT.709, AAC, −14 LUFS). Block sound cues are mixed in |159160## Debugging161162- A build error shows as a red overlay in preview. The renderer prints it and stops.163- A `say()` miss logs `narration has no word "…"`. Match the text as written in `vo` ("seventy", not "70").164- Something is invisible? Check the scene's beat window, `data-until`, a `from()` tween that never ends, or an opacity tween that fights an `onFrame` function.165- Timing feels off? Run `clearframe timing`. The rows marked `est` have no recorded voice yet.166- Slow renders: `--draft` is half-resolution JPEG; `--workers` defaults to half your CPU cores (max 6).