Plugin installs: Before setup or freshness commands, follow plugin execution rules when this skill is inside a HyperFrames plugin. Standalone installs keep the update instructions below.
First, keep this skill fresh — confirm with the user before running:
npx hyperframes skills update embedded-captions. A fast no-op when everything is current; otherwise it refreshes this skill plus the core domain skills it depends on before you rely on them.
Embedded Captions
One catalog, picked up front (CATALOG.md — 35 identities; the engines behind it are backend detail). Standard (default) builds a clean verbatim rail (lower-third subtitle carrying most text) + an embed climax composited into the scene behind the subject at the peak. Cinematic is pure embed — no rail, every caption composited behind the subject (hero typography, accumulation, occlusion as the effect). Theme is a complete themed constitution — body paradigm × hero setpiece × front fx × plate reaction, composed from registries (themes/README.md): ordnance terminal neonsign stardust stomp. Most explainer / voiceover is Standard; embed is the scarce, earned peak — embedding every word is the common mistake; Theme is for VFX-grade asks ("explosion", "VFX", "looks like AE").
Runtime prerequisites
Plugin installs use the bundled, manifest-pinned CLI for matting, transcription, and rendering; no source checkout is required. The local preview and caption measurement helpers also need Sharp, Puppeteer (with its Chromium browser), and GSAP. Install these in the caption project, not inside the read-only plugin:
npm install --prefix <project> --save-dev --save-exact [email protected] [email protected] [email protected]
Keep the project's lockfile. If these dependencies already exist, use its locked versions instead of overwriting them. Bash and FFmpeg/ffprobe must be on PATH. Matting and transcription may download their own models on first use.
Rendering waits for the CLI to exit successfully before compositing. The old HF_TIMEOUT_S shell watchdog is no longer used: a large partial file is not proof that rendering finished. An explicit built-checkout argument or HYPERFRAMES_ROOT selects the contributor CLI instead of the plugin pin. Cancel a stalled render normally through the CLI/terminal; the caption helper does not force-kill or recover a render from a process snapshot.
Operational flow (TL;DR)
Routed through /hyperframes, the intent layer confirms only the input (which clip) and announces the identity pick as a deferred ask — the shortlist needs the probed clip, so it stays at step 1 below; the layer's run-shape questions don't apply (the footage is untouched, there is no storyboard to review). A BRIEF.md, when present, carries the confirmed input and any user notes — read it first.
The craft prose below is long; the pipeline itself is short — and everything deterministic is computed or compiled, never hand-written:
- Decision gate (refuse bad clips) → pick ONE identity from CATALOG.md (35 identities; engine/compiler derived by lookup — never surface a mode/category question)
hyperframes init(skip it if the project dir already exists with the video inside —matte.cjs/transcribe.cjsadopt any video in the dir as source.mp4) →bash scripts/prepare.sh <project>(matte ∥ transcribe ∥ audio-envelope in parallel, then safe-zones v2 with scene palette/optics/lighting — one command, nothing forgotten)- author a small JSON of creative choices (read
safe-zones.jsonfirst): Cinematic →cinematic.json→make-cinematic.cjs(derivesplan.jsonand compiles it); Theme →theme.json→make-theme.cjs(rail/panel/poem/takeover paradigms;anchoris the quiet rail default) - Visual QA:
node scripts/preview-frames.cjs <project>→ faithful composite previews in ~2s/frame (no render). Check § Visual QA before paying for a render. render-and-composite.sh→ gates (timing / occlusion+hero / overflow / hand-off) →final.mp4
Load-bearing rules people miss:
- rail (default) + embed (promotion).
drop(filler, not shown) /rail(verbatim lower-third subtitle, in front, carries most text) /embed(a peak word composited behind the subject). Standard mode does both, embedding only the peak(s). See § Caption model. - The video is delivered UNTOUCHED (Standard/Cinematic; Theme mode's PLATE budget is the one sanctioned exception — register-gated reaction beats (charge-dim, punch, shake, grain) defined per theme DNA and applied AFTER the matte composite so subject+text+plate move as one frame) — captions are the only thing added; the matte just lets the subject occlude the embed track. Never grade/recolor/scanline the footage.
- Two rulebooks: rail → references/rail.md (thin), embed craft → references/composition-craft.md (rich, embed-only). Skim by need.
Caption model — rail + embed
Every spoken phrase is one of three things:
| What | How it's shown | |
|---|---|---|
| drop | filler — um/uh, stutters, self-corrections | not shown |
| rail | the default — ordinary spoken content (verbatim) | clean lower-third subtitle, in front, readable. A punch word can get an inline emphasis highlight (accent colour / active-word pop) — it stays on the rail. |
| embed | a promoted peak — the headline beat | one big word composited behind the subject (matte occlusion), designed entrance + exit |
The rail carries most of the text; embed is the scarce, earned peak. Scarcity is per beat/block, not per clip: ≤1 hero per block (thought), never two co-visible, ≥ a beat of air between hero windows (the compiler warns under 0.6s). A short clip → usually 1–2; a long explainer → ~one per section. Among multiple heroes, the largest authored one is the APEX (it alone gets the full lockup embed + width-fit raise); smaller ones are MINOR peaks that ride their column as oversized emphasis lines (fg, damped motion) — not every beat needs the matte showcase, which is exactly what keeps the apex an event. Embedding every word is still the common mistake.
Rail-surface identities build exactly this (rail = rail.html, embed = the climax in index.html). Column-flow identities drop the rail and make everything embed-style — recommend them only for mood-over-verbatim asks, never for explainer / voiceover where the words must read (CATALOG.md encodes this per identity).
Step 0 — pick ONE identity from the CATALOG
One front-end, three engines behind. The user picks an IDENTITY from CATALOG.md (35 entries: 10 classic + 25 themed); the engine, compiler and authoring file are derived by lookup from the catalog row. Never surface "Standard vs Cinematic vs Theme" as a question — those are backend names (a product has one UX even with several engines). The catalog encodes everything routing needs: reading surface, voice, recommend-for, scene needs, adjacency notes for the genuinely-close pairs (loud↔ordnance, neon↔neonsign, cream↔stardust).
The identity pick is a preference gate (../hyperframes/references/brief-contract.md § 1): in autonomous mode ("surprise me" / "decide for me"), pick from your shortlist yourself and state the one-line why instead of asking.
Procedure: probe the clip → shortlist 2–3 identities from the catalog → recommend ONE with a one-line why → the user picks (autonomous mode: you pick, stating the why) → author that identity's file. Identities are engine-locked (no cross combos; opening one is a validation event — see dna/README.md).
Always present your recommendation and let the user pick before you author. Don't silently default.
(The full identity table lives in CATALOG.md — single source of truth for routing. The engine docs below describe each backend's authoring contract.)
CATALOG.md is the whole answer space here: this workflow does not search the HyperFrames component registry. The composition workflows run npx hyperframes catalog before authoring a named look; this one must not. Its engines are locked compilers that consume cinematic.json / theme.json and emit the composition themselves, so a registry item — the caption-* blocks included — has nothing to mount into. A registry block styles text on a designed canvas; this skill burns captions into somebody's footage through a matte. When no identity fits the ask, say so and pick the nearest, rather than reaching outside the catalog.
Recommendation heuristic: use the "Shortlisting heuristics" in CATALOG.md — they are identity-level (e.g. "explosion" shortlists ordnance/stomp/terminal/loud and picks by WHAT should explode), never category-level. Unsure → anchor.
- Cinematic → write
cinematic.jsonfor a locked template, compiled bymake-cinematic.cjs. - Theme → read themes/README.md, author
theme.json, runscripts/render-theme.sh(compiles + renders + plate reaction → final_fx.mp4).
Decision gate — RUN FIRST
Probe the video and classify the scene before either mode.
ffprobe <video.mp4> # specs
ffmpeg -ss <t> -i <video.mp4> -vframes 1 sample.png # at 20/50/80%
Read the samples. Refuse if:
- Multiple speakers / hard cuts (split & render each shot, or refuse)
- No human subject (this skill is for talking-head)
- Under 3 seconds, no speech, or face never clearly visible —
transcribe.cjswarns when audio is near-silent (Whisper hallucinates words like "Thank you." over silence); heed it and refuse rather than caption fabricated words - Source already has burned-in captions / subtitles / heavy text graphics — adding a second caption system conflicts and the footage ships untouched (no covering/inpainting). Burned text often appears only mid-clip: sample a 1fps contact sheet (
ffmpeg -i in.mp4 -vf "fps=1,scale=160:-1,tile=10x5" sheet.png), don't trust 3 spot frames. - Transcript is garbage — non-native/heavy-accent speech can transcribe into confident gibberish. Sanity-read
transcript.jsonbefore authoring; if it doesn't parse as language, tryWHISPER_MODEL=mediumonce, else refuse (a verbatim rail of fabricated words is worse than no captions). - Busy handheld with fast motion (matte flickers)
Pre-flight probes (cost nothing, prevent the worst failures)
- Shot-cut probe. Sample frames at 20%, 50%, 80%. If a different subject/scene appears, trim the clip before the cut.
- Letterbox / pillarbox probe. Black bars on the first frame? Compute safe content rect and constrain caption placement inside it.
- Luminance probe. Sample the caption region's average luminance —
under 60→ light text reads as-is,60-180→ add the glyph scrim,180+→ opaque text + scrim (never bare light text). Cinematic templates are cream+screenand LOCKED — use this probe to pick a fitting identity (bright scenes →ink, or the opaque-railanchortheme), never to recolour one. - Identity recommendation by tone (you recommend; the user picks — see Step 0 + CATALOG.md). explainer / interview / must-read words → rail/panel-surface identities; poetic / social / "cinematic" → column-flow identities by register; "explosion / VFX / named worlds" → themed identities. When unsure →
anchor(words read, scene safe) — but present a shortlist and let the user choose.
Pipeline — 5 steps
1. hyperframes init <project> --non-interactive --video <video.mp4> --skill=embedded-captions
2. bash scripts/prepare.sh <project> # matte ∥ transcribe (parallel) → safe-zones. One command.
# → frames_fg/ transcript.json safe-zones.json
3. [AGENT STEP — the only creative step] author a small JSON; see below by mode
Cinematic: author cinematic.json → node scripts/make-cinematic.cjs <project>
Theme: author theme.json → bash scripts/render-theme.sh <project> (compiles + renders + plate fx)
4. node scripts/preview-frames.cjs <project> # ~2s/frame composite previews → § Visual QA (BEFORE the render)
5. bash scripts/render-and-composite.sh <project> # gates → final.mp4 + history/ snapshot
(Theme mode: SKIP steps 3b/5 — render-theme.sh already runs compile + render-and-composite
+ _postfx.sh; the deliverable is final_fx.mp4, final.mp4 is pre-plate-reaction)
Step 1's init checks the installed skills against the latest on GitHub and updates the global set if any are out of date.
Step 3 differs by mode:
Step 3 — Cinematic mode (pure embed)
- Read
safe-zones.jsonfirst. Narration planes go inzones.hugLeft/hugRight— clean strips ABUTTING the silhouette (text far from the body reads as floating, not embedded; far corners are the fallback, not the default). The hero defaults toheroAnchor/heroBands.best(centered ON the subject, ~30–55% occluded).recommendation:"fg"moves NARRATION in front for legibility; the hero stays embedded wheneverheroBands.feasible— hero-fg is the last resort. - The DNA is the identity you picked in Step 0 — open
clients/<identity>/dna.jsoninstead of guessing: font, colour palette, scale, timing, and any identity-specific constraints (e.g.stardustwants multi-column,neonwants dense). The DNA also signals whether the identity supports screen blending (blendMode), fallback typography for overflow, and how much occlusion % to expect for the hero lockup. - Author
cinematic.json:narration: array of {text, timeIn, timeOut, zone: "hugLeft"|"hugRight"}. Narration is the support text for each beat.hero: {beat, text, zone: "heroAnchor"|"heroBands.best"} — the APEX of the clip.minorPeaks: [ {text, timeIn, timeOut, zone} ] — less prominent, occluded behind subject.scarcityRule: boolean. Whentrue, enforce the ≤1 hero per block / ≥0.6s air rule.dropWords: [strings] — words to hide entirely.
- Run
node scripts/make-cinematic.cjs <project>— this readscinematic.json, consults DNA, derivesplan.json(explicit per-word timing and placement), and compiles the composition. It may also write agates.jsonfor step 5.
Step 3 — Theme mode (complete thematic constitution)
- Read
safe-zones.jsonfirst—theme templates may expect specific safe-zone dimensions; if mismatch, warn and use defaults. - The identity picked in Step 0 maps to a theme registry folder under
themes/. Readthemes/<theme>/README.mdfor the full authoring contract, including:bodyParadigm: how the main caption block behaves (e.g.rail,panel,poem,takeover)heroSetpiece: the hero animation type (e.g.lockup,explosion,glitch,scale)frontFx: optional front-layer effects for the rail (e.g.grain,glow,none)plateReaction: a budget for affecting the background plate (e.g.charge-dim,punch,shake,grain)
- Author
theme.json:identity: the name from the catalogtheme: the theme string (e.g.ordnance,terminal)narration: same structure as cinematic narration, but zone choices may be overridden by the theme's bodyParadigmhero: same structure as cinematic herominorPeaks: optionalplateFx: {reaction: "shake", intensity: 0.3} (optional; overrides the default plate reaction from theme DNA)
- Run
bash scripts/render-theme.sh <project>— this script:- Reads
theme.json - Runs
make-theme.cjsto compile and apply the theme - Runs
render-and-composite.shinternally - Runs
_postfx.shto apply plate reactions - Outputs
final_fx.mp4(final with plate effects) andfinal.mp4(without plate effects)
- Reads
Visual QA
Before rendering the full clip, always run previews:
node scripts/preview-frames.cjs <project>
This produces one PNG per 30 frames (~1s steps) in a preview/ subfolder within the project dir. Each preview shows the composited scene with both rail and embed captions (if applicable) at their correct positions, with subject matte and occlusion. Open a few representative frames and verify:
- Text is readable and not cut off
- Embed captions are properly occluded behind the subject
- No visual collisions between narration planes
- Colour palette matches the identity expectations
- Spacing and timing look correct
If the previews look wrong, adjust the JSON and re-run make/preview. Only proceed to step 5 when previews are satisfactory.
References
- Rail rules: references/rail.md
- Embed composition craft: references/composition-craft.md
- Identity catalog: CATALOG.md
- Theme registry README: themes/README.md
- Plugin installation: plugin-installation.md
- Brief contract: brief-contract.md
- DNA documentation: dna/README.md
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Embed text not visible behind subject | matte not generated or incorrect heroBands | Check frames_fg/ exists; re-run prepare.sh with --force-matte. Verify safe-zones.json has heroBands.feasible = true. |
| Text is cut off at screen edges | safe zones wrong or narration zone not hugging silhouette | Re-run prepare.sh (or manually edit safe-zones.json). For cinematic mode, ensure zones use hugLeft/hugRight. |
| Preview shows text floating far from subject | zone not hugging silhouette | In cinematic.json, change zone to hugLeft or hugRight; for hero, use heroAnchor or heroBands.best. |
Theme mode outputs final.mp4 without plate effects | Theme script didn't run _postfx.sh | Delete final.mp4 and re-run render-theme.sh; the deliverable is final_fx.mp4. |
| Whisper transcribes silent audio as words | Near-silent audio triggers confabulation | Heed the transcribe.cjs warning and refuse the clip. |
| Matte flickers on fast motion | Handheld/busy camera | Refuse the clip; this skill requires stable subject. |
CLI reference
# Initialize a project
hyperframes init <project> --non-interactive --video <video.mp4> --skill=embedded-captions
# Prepare matte + transcription + safe zones
bash scripts/prepare.sh <project>
# Cinematic mode: author → compile
# (First: write cinematic.json)
node scripts/make-cinematic.cjs <project>
# Theme mode: author → compile + render
# (First: write theme.json)
bash scripts/render-theme.sh <project>
# Visual preview (before final render)
node scripts/preview-frames.cjs <project>
# Final render (Standard/Cinematic only; Theme uses render-theme.sh)
bash scripts/render-and-composite.sh <project>
# Final output:
# Standard/Cinematic: project/final.mp4
# Theme: project/final_fx.mp4 (also final.mp4 for pre-fx)
Appendix: Supported identities (summary)
See CATALOG.md for the full list of 35 identities with: name, surface type (rail/panel/column), recommended use cases, tone, scene needs, and adjacency notes. The catalog is the single source of truth for routing decisions.