vidforge — Scripted Multi-Language Product Tutorial Videos
Videos are code. One Playwright scenario (scenario.mjs) + one multilingual narration file (script.yaml) produce crisp H.264 MP4 tutorials and .vtt subtitle tracks in any language and any layout (docs-16x9, social-9x16, raw-16x9).
Engine & CLI root: /Users/nikolaytv/workspace/vidforge (alias VF=/Users/nikolaytv/workspace/vidforge/bin/vidforge.mjs).
Detailed references inside this skill folder:
references/capture-contract.md—stageAPI,timeline.json,audio.json, locale-independent selectorsreferences/hyperframes-rules.md— pinned HyperFrames invariants (fgrid,fromTo, H.264, approval gate)references/layouts-and-effects.md—docs-16x9,social-9x16,raw-16x9, safe-zone guard, SFX & ducked music
Two Operating Modes
Choose the mode that matches the user's request:
Mode A — Feature Review Demo (PR / autonomous-cycle / showing a finished feature)
Use when demonstrating a new feature or fix for owner review instead of a wall of text and static screenshots:
- Language & quality: single language (
--lang ruby default unless the user works in English), full 1080p (docs-16x9, no--draft— sharp and pleasant to watch). - Burned captions ON (
--captions): standalone MP4s opened in QuickTime, Telegram, or chat don't load external.vtttracks, so pass--captions(with auto safe-zone guard) and--sfx. - Duration: match the feature's real acceptance flow — 20–40 s for a focused change, or several minutes (as many steps as needed) for complex multi-screen features. Never artificially rush or skip important states.
- No git pollution: create the temporary scenario folder outside git (e.g.
/tmp/vidforge-demos/<feature-slug>/) and point--configat the product's adapter (for ReplyBuddy:frontend/help/videos/video.config.mjs). Hand the rendered 1080p MP4 file path directly to the user.
DEMO=/tmp/vidforge-demos/<feature-slug>
CFG=/Users/nikolaytv/workspace/buddy/frontend/help/videos/video.config.mjs
node $VF record $DEMO --config $CFG --lang ru --rehearsal
node $VF voice $DEMO --config $CFG --lang ru
node $VF record $DEMO --config $CFG --lang ru
node $VF build $DEMO --config $CFG --lang ru --layout docs-16x9 --captions --sfx
node $VF render $DEMO --lang ru --layout docs-16x9
Mode B — Help Center / Product Documentation Tutorial (published, multi-language)
Use when publishing persistent tutorials into documentation (e.g. VitePress Help Center) or marketing:
- Clean 1080p video +
.vtttracks:docs-16x9defaults toburnCaptions: falseso HTML5<video><track kind="subtitles">never produces double subtitles when switching languages. - Multi-language & multi-layout: author
script.yamlfor all target languages (ru,en, ...), keepscenario.mjslocale-independent, and emitdocs-16x9(docs) +social-9x16(vertical reels with burned word-highlighted captions). - Keep focused: 4–6 steps, 20–45 s per single user goal; commit
scenario.mjs+script.yamlunder the product'svideos/folder.
Core Design Rules
- One deterministic builder, zero bespoke HTML per video. Never hand-author HyperFrames HTML/GSAP for individual tutorials. An agent writes only two small files per tutorial:
scenario.mjs(~30 lines) andscript.yaml(~15 lines).build.mjscompiles every layout deterministically. - One video = one fresh helper. When producing a batch of tutorials (e.g. 5 help-center articles), spawn a fresh subagent per tutorial so context never bloats across renders.
- Never skip the Approval Gate. Always inspect
build/approval-<lang>-<layout>.html(and its extracted step frames) BEFORE running a full 1080p HyperFrames render. - Never guess selectors or API shapes. Inspect the product's actual DOM/components first, run
--rehearsal(~5s) to prove selectors work, and verify rendered frames with your own eyes. - No Whisper needed for TTS tutorials. xAI
POST /v1/tts(xai/grok-tts) withwith_timestamps: truereturns character-level timestamps natively (graph_chars+graph_times).
Step-by-Step Workflow
0. Preflight check (once per session / new product)
node $VF doctor [projectDir]
Checks Node >= 22, FFmpeg/FFprobe, pinned HyperFrames (HF_VERSION), built-in CC0 SFX (click.wav, step.wav), and xAI/Gateway credentials (LLM_GATEWAY_URL + LLM_GATEWAY_TOKEN or direct XAI_API_KEY; --mock works offline for pipeline verification). Placing credentials once in /Users/nikolaytv/workspace/vidforge/.env (gitignored) makes them available automatically across all projects and /tmp/vidforge-demos/* runs.
1. Wire the product adapter (once per product repository)
Copy templates/video.config.example.mjs to <product-repo>/videos/video.config.mjs (for ReplyBuddy Help Center: frontend/help/videos/video.config.mjs) and fill:
baseUrl— dev/staging URL of the productauth(page, context, { config, locale })— dedicated QA/demo login (never hardcode passwords; read from gitignored credentials/env)setLocale(context, lang)— switch UI locale cleanly. Gotcha: if the backend returns an account language (likeGET /users/me) that overrideslocalStorage, intercept thatGETwithcontext.route(...)to overridelanguagein the browser without mutating the QA account on the server!setTheme(context, theme)—light/darkhideSelectors— cookie banners, chat widgets, debug barsbrand—name,accent,onAccent,bgStart,bgEnd,captionBg,fontFamilytts— default xAI model (xai/grok-tts),voiceByLang(eve,ara,rex,sal,leo)effects— optionalsfx(enabled,clickRelDb: -14,stepRelDb: -16) andmusic(enabled,file,baseDb: -22,duckDb: -32,fadeOutS: 0.8)
2. Storyboard before coding
Write script.yaml first:
- Mode A (Feature Review Demo): include as many steps as the real acceptance flow needs — from 20–40 s for a focused change up to several minutes for a complex multi-screen feature. Single language (
ruby default). - Mode B (Help Center tutorial): keep focused on one user goal (4–6 steps, 20–45 s total) and put every target language (
ru,en,es, ...) underlanguages.<lang>.steps.<step_id>. - Each step sentence: 10–18 words, active present tense, says what to do and why (not raw button clicks only).
- Do NOT use em-dashes in short social captions if they split awkwardly; keep punctuation clean so subtitle chunking lands naturally.
3. Write locale-independent scenario.mjs and rehearse
Write videos/<slug>/scenario.mjs using stage.step(id), stage.click(loc), stage.type(loc, text), stage.focus(loc), stage.cut(fn):
- Locale-independent selectors: prefer
data-testid, semantic CSS structure,input[type=...],href^="..."over localized visible button labels so ONE script records RU, EN, and ES UIs! - Clean state: put pre-recording cleanup in
prepare(stage)and post-recording off-camera cleanup incleanup(stage)so QA workspaces stay clean. - Rehearse first (5–10 seconds, no encoding):
node $VF record ./videos/<slug> --lang ru --rehearsal
Fix any broken selector here before recording a single frame.
4. Generate voiceover & timestamps FIRST (voice)
Audio-first order lets record hold each live screen for the exact voiceover duration (zero freeze-frames, zero A/V drift):
# Live xAI TTS (via llm-gateway or XAI_API_KEY)
node $VF voice ./videos/<slug> --lang ru,en
# Offline/CI smoke test without API key
node $VF voice ./videos/<slug> --lang ru,en --mock
- Outputs
-16 LUFS48 kHz WAVs +build/audio-<lang>.jsonwith word-level timings. - SHA-256 cached in
build/tts-cache/: editing one sentence only re-synthesizes that one step.
5. Record real UI (record)
# Native localized UI for each language (recommended for Help Center)
node $VF record ./videos/<slug> --lang ru
node $VF record ./videos/<slug> --lang en
# Optional native mobile capture for 9:16
node $VF record ./videos/<slug> --lang ru --viewport mobile
- Outputs
build/raw-<locale>-<theme>-<viewport>.mp4+ frame-snappedbuild/timeline-<locale>-<theme>-<viewport>.jsonwith click(x, y)coordinates and elementbbox. - To re-voice an existing capture in a new language without re-recording the browser, skip
recordfor that language and pass--capture <existing-capture-key>tobuild.
6. Build layouts, effects, VTT & Approval Sheet (build)
# Feature Review Demo (standalone MP4 with burned captions + UI SFX)
node $VF build /tmp/vidforge-demos/<slug> --config <path/to/video.config.mjs> --lang ru --layout docs-16x9 --captions --sfx
# Landscape Help Center (clean video + .vtt) + Vertical Social from the same recording, with UI SFX
node $VF build ./videos/<slug> --lang ru --layout docs-16x9,social-9x16 --sfx
# With licensed background music (auto-ducked under voice)
node $VF build ./videos/<slug> --lang ru --layout social-9x16 --sfx --music ./assets/bed.mp3
STOP AND CHECK THE APPROVAL GATE:
- Read
build/plan-<lang>-<layout>.json— verifywarningsis empty (or justified), checkholdDurationper step, and note anycaptionAutoFlipped: truesteps (safe-zone guard moved caption to top because active elementbboxsat in the bottom 30%). - Inspect at least 2 extracted step PNGs in
build/approval-frames-<lang>-<layout>/(start + modal/save step) to verify:- UI is in the intended language and theme,
- no sensitive/personal data, cookie banners, or broken layouts appear,
build/<slug>-<lang>.vtthas crisp, readable subtitle cues.
7. Preview, Render & Automated QA (render)
# Fast 720p preview (~20s)
node $VF render ./videos/<slug> --lang ru --layout docs-16x9 --draft
# Full 1080p H.264 8-bit yuv420p BT.709 +faststart master + automatic QA
node $VF render ./videos/<slug> --lang ru --layout docs-16x9
node $VF render ./videos/<slug> --lang ru --layout social-9x16
- Runs
hyperframes lint --json(fails on any lint error), renders via pinned HyperFrames with--video-frame-format png --sdr --strict, re-encodes to browser-safe H.264 8-bityuv420p, copies<slug>-<lang>.vtt, and executesqa. out/<video>.mp4.qa.jsonMUST report"pass": true:h264+yuv420p, exact target resolution,- A/V duration drift <= 250 ms,
- no black frames in final 0.5 s,
- integrated loudness in range.
8. Final Visual Verification (Mandatory)
Never hand over a rendered video solely because qa passed. Extract 2–3 frames from the final MP4 and inspect them with your eyes:
ffmpeg -y -loglevel error -ss 1.5 -i out/<file>.mp4 -frames:v 1 build/verify-1.png
ffmpeg -y -loglevel error -ss 12.0 -i out/<file>.mp4 -frames:v 1 build/verify-2.png
ffmpeg -y -loglevel error -ss 21.0 -i out/<file>.mp4 -frames:v 1 build/verify-3.png
Check: crisp readable text (Cyrillic & Latin), cursor & click ring aligned with UI target, zoom keeps key UI inside frame, captions never cover the active input/button, clean title/header in 9:16.
9. Optional Cover / Thumbnail Generation (cover)
When a tutorial or landing embed needs a custom poster image (uses xai/grok-imagine-image-2.0 via llm-gateway or direct XAI_API_KEY):
node $VF cover ./videos/<slug> --prompt "Minimal dark SaaS illustration of a knowledge base card glowing purple" --aspect-ratio 16:9
Troubleshooting & Gotchas
- Double subtitles in Help Center
<video>: Never combine burned-in captions (--captions) with an enabled<track default>subtitle track.docs-16x9defaults to clean video (burnCaptions: false) +.vttsidecars;social-9x16defaults to burned word-highlighted captions. - Dashboard UI stayed in English during
--lang ru: Server user settings (GET /users/me) overrodelocalStorage. Intercept the profile response invideo.config.mjssetLocale()viacontext.route(...). hyperframes renderexited withrender_cancelled_parent_exited: Never launchrenderwithnohup ... &; always run it as a foreground/tracked process.- Static freeze-hold warning (> 2.5 s) in
approval.html: Audio for that language is much longer than the recorded UI step. Either tighten the narration copy inscript.yamlor re-record audio-first (voicethenrecord --lang <lang>). - Mock audio vs real xAI voice: Videos built with
--mockare for pipeline/layout verification only — never publish mock-voiced MP4s to production docs. Re-runvoice(without--mock) →build→renderto swap in real xAI speech without re-recording the browser.
Reporting Format
- Outcome first: which videos/layouts/languages were built, duration & file size, QA status (
PASS/FAIL), and whether voiceover is real xAI TTS or--mock. - Three verification buckets (never mix them):
- Verified visually on rendered frames (and
approval.html), - Verified automatically by
qa.mjs/ tests (ffprobe, A/V sync, loudness, H.264), - Not yet verified (e.g. real xAI TTS audio listen, production deploy).
- Verified visually on rendered frames (and