Skip to Content
Pipeline Stages

Parse

Extract structured data from Playwright trace.zip files.

The .parse() stage reads a Playwright trace archive and extracts all the data needed for video generation.

Basic usage

import { Recast } from 'playwright-recast'

const pipeline = Recast
  .from('./test-results/trace.zip')
  .parse()

You can also point to a directory containing trace files:

const pipeline = Recast
  .from('./test-results/')
  .parse()

What gets extracted

The parser reads the trace.zip and produces a structured representation containing:

DataSourceUsed by
ActionsUser interactions (click, fill, type, navigation)Speed processing, click effects, auto-zoom
ScreenshotsFrame-by-frame page capturesVideo frames
Network eventsAPI calls, resource loadingSpeed classification (network wait)
Cursor positionsMouse coordinates at each actionCursor overlay, click effects, auto-zoom
BDD step titlesplaywright-bdd Gherkin step namesSubtitle generation via .subtitlesFromTrace()

CLI equivalent

# Parse is implicit in CLI mode — it always runs
npx playwright-recast -i ./test-results/trace.zip -o demo.mp4

Source video resolution

The renderer needs a source .mp4/.webm to apply speed, zoom, overlays, and subtitles against. Two layouts are supported:

  • Sibling .webm (preferred) — when your Playwright config enables recordVideo (e.g. use: { video: 'on' }), the trace's sibling .webm is auto-discovered. Native frame rate, best quality.
  • Standalone trace.zip — when no sibling .webm exists (trace downloaded from the trace viewer, or test run without recordVideo), the pipeline assembles a CFR 25fps .mp4 from the screencast JPEG frames stored inside the trace. Variable capture cadence — .webm is preferred when available.

Sharp text when zooming

A zoom enlarges source pixels, so a 1920px recording rendered at 1440p with a 1.8x zoom upscales text 2.4x and it goes soft. Record at a higher device scale instead:

// playwright.config.ts
import { defineConfig } from '@playwright/test'
import { recastVideo } from 'playwright-recast/config'

export default defineConfig({
  use: {
    ...recastVideo({ viewport: { width: 1920, height: 1080 }, scale: 2 }),
    trace: 'on',
  },
})

The page still lays out at 1920x1080, but the video is recorded at 3840x2160. recastVideo() sets the three things that have to agree, each of which fails silently on its own: --force-device-scale-factor (headless Chromium ignores deviceScaleFactor for the video), video.size of viewport x scale (Playwright pads a smaller frame with gray instead of scaling it), and headless mode (headed Chromium follows the OS display scale). Decimal scales work: for a sharp 1.8x zoom into 1440p, scale: 2.4 records 4608x2592. The scale is rounded up to the next one that gives whole, even device pixels (1.3334 records at 1.35 for 1920x1080), since only those record without gray padding or rescaling. In general, scale = max(1, max zoom x max(output width / viewport width, output height / viewport height)). Chromium only.

A higher scale costs render time and disk, growing with the recorded pixels (scale²). The render grows less than that, since voiceover and timing don't depend on it: 2 -> 2.4 is 44% more pixels and rendered 25% slower on a 3.5-minute screencast.

The renderer warns once the source is upscaled by more than 1.25x at the tightest zoom, and names the recording size that would be sharp.

Tips

  • The trace file must be generated with Playwright's tracing enabled (--trace on or via playwright.config.ts).
  • .parse() should always be the first stage after .from(). Other stages depend on the parsed trace data.
  • Parsing is fast — the trace is read once and the structured data is passed through the pipeline.

On this page