Skip to main content
The Renderer class is the primary interface for rendering browser-based animations to video files. It orchestrates the entire rendering pipeline including browser automation, frame capture, and FFmpeg encoding.

Constructor

Creates a new Renderer instance with the specified configuration.
RendererOptions
required
Configuration object for the renderer. See render options for all available fields.

Basic usage

Methods

render

Renders a composition to a video file.
string
required
URL of the HTML page containing the animation composition. Can be a local file path (file://) or HTTP URL.
string
required
File path where the rendered video will be saved. The file extension determines the container format (e.g., .mp4, .webm, .mov).
RenderJobOptions
Optional job-specific configuration including progress callbacks, abort signals, and tracing. See render options for details.

Example

diagnose

Runs diagnostic checks to verify browser and FFmpeg capabilities. Returns an object containing:
  • browser: Browser diagnostics including GPU info, WebCodecs support, and rendering mode capabilities
  • ffmpeg: FFmpeg diagnostics including version, available hardware acceleration methods, and encoders

Example

Rendering modes

The Renderer supports two capture strategies:

Canvas mode

Best for: Canvas-based animations, WebGL content, game engines
Canvas mode uses WebCodecs API for efficient video encoding directly from canvas frames. Falls back to image capture if WebCodecs is unavailable.

DOM mode

Best for: CSS animations, DOM-based content, text animations
DOM mode captures viewport screenshots using Playwright, providing pixel-perfect rendering of CSS and DOM elements.

FFmpeg integration

The Renderer automatically manages FFmpeg for video encoding:

Default configuration

Custom FFmpeg settings

Hardware acceleration

The renderer validates that the specified hwAccel method is available in your FFmpeg build. Check diagnostics output for available acceleration methods.

Audio integration

Single audio file

Multiple audio tracks

Subtitles

Subtitles require video transcoding. You cannot use videoCodec: 'copy' when subtitles are enabled.

Input props

Pass data to your composition at runtime:
Access props in your composition:

Deterministic rendering

Ensure reproducible renders across different machines:
The renderer automatically:
  • Overrides Math.random() with a seeded PRNG
  • Controls time progression deterministically
  • Prevents race conditions in async operations

Browser configuration

Default browser arguments (always applied):

Error handling

The renderer captures and propagates:
  • Page JavaScript errors
  • Browser crashes
  • FFmpeg encoding failures
  • Abort signal cancellations

Console output

The Renderer logs detailed information during rendering: