Docs
GIF and video
trace-avatar-render, and Save as video in the browser.
trace-avatar-render
Plays a trace on your real app in headless Chromium and writes a GIF or an MP4. Long waits are cut, a stalled guide fails the render (so a docs GIF that no longer matches the app fails CI), and masked fields only ever get dots.
npx trace-avatar-render invoice.trace.json --url http://localhost:3000/app --out invoice.gif| Option | |
|---|---|
--url | the page the guide starts on (required) |
--out | .gif or .mp4, repeatable (required) |
--mode perform --allow-perform | Do it for me: it really clicks and types, so use a sandbox account |
--storage-state | a signed-in Playwright session |
--frame browser | the app in a browser window on a background |
--camera | zoom in on each click and typing step; pair with --scale 2 |
--captions burn|vtt|both | burned-in captions, or VTT captions and chapters |
--poster, --title-card, --end-card | a PNG, and cards before and after |
--blur, --hide | blur or hide selectors before capture |
--voice | MP4 narration of each caption |
--allow-stall | render a stalled guide instead of failing |
From code
import { render } from 'trace-avatar-render';
const r = await render({
trace: './invoice.trace.json',
url: 'http://localhost:3000/app',
out: ['invoice.gif', { file: 'invoice.mp4', fps: 30 }],
storageState: './auth.json',
frame: 'browser', camera: true, captions: 'both', poster: true, titleCard: true,
});
r.durationMs; r.outputs;render rejects with a RenderError (with .screenshot) when the guide stalls, errors, or can’t start.
Save as video, in the browser
No server needed: trace-avatar/export records the guide playing on the page itself. The browser asks to share the tab, the guide plays from step 1, and you get a GIF or a video (WebM, or MP4 in Safari).
import { saveVideo } from 'trace-avatar/export';
const v = await saveVideo(controller, {
format: 'gif', // or 'video'
area: document.querySelector('#app'), // what to keep; default the whole viewport
onProgress: (p) => console.log(p.phase), // 'asking' | 'recording' | 'encoding'
});
v.download();- It rejects with an
ExportErrorwhosereasonisunsupported,denied,cancelled,stalledorfailed. - The GIF encoder loads only for a GIF and runs in a worker; a strict Content-Security-Policy needs
worker-src blob:. - A guide that changes pages with a full page load can’t be saved this way; use trace-avatar-render for those.
The full reference is in the README on GitHub.