Skip to main content

Recording

Creating a Recorder​

import { Recorder } from "demo-as-code";

const recorder = new Recorder("./output");

The recorder manages a headless Chromium instance and captures telemetry.

Initialization​

const page = await recorder.initialize({
size: { width: 1920, height: 1080 },
initialMousePos: { x: 500, y: 500 },
initialZoom: 1,
crf: 4,
});

Options​

OptionTypeDefaultDescription
size{ width, height }1920x1080Viewport dimensions
initialMousePos{ x, y }{ x: 500, y: 500 }Starting cursor position
initialZoomnumber1Starting zoom level
crfnumber4Video quality (lower = better)

Tracking Zoom​

Call logZoom() to mark zoom transitions:

// Zoom in before important interaction
recorder.logZoom(2.5);
await page.click(".important-button");

// Zoom back out
recorder.logZoom(1.0);

The post-processor interpolates smooth transitions between zoom points.

Mouse Tracking​

Mouse movements and clicks are captured automatically via injected event listeners. No manual setup required.

Saving​

await recorder.closeAndSave();

This flushes the browser, runs the video pipeline, and cleans up temporary files.