Skip to main content

Module video

Module video 

Source
Expand description

Video — page video capture via CDP Page.startScreencast.

Playwright records a real video file (muxed by a bundled encoder). CDP has no native video muxing: the closest primitive is Page.startScreencast, which streams individual captured frames as base64-encoded images through the Page.screencastFrame event.

This module implements capture on top of that primitive. Video::start subscribes to Page.screencastFrame and writes each incoming frame to the configured output path; Video::stop ends the cast.

§Scope / caveats

  • The output is a sequence of captured frames, not a muxed video file. By default each frame is written as its own image file (<path>/frame-NNNNN.png when path is a directory). When path points at a single file, frames are appended as raw image chunks (a “filmstrip”), which is still not a playable video.
  • Producing an actual video (.webm/.mp4) requires piping these frames to an external encoder (e.g. ffmpeg); that encoding step is intentionally out of scope here. Callers wanting a true video should stop the cast, then feed the captured frames to an external encoder.
  • Video::path returns the configured output path (Playwright shape).

The handle is cheaply cloneable (Arc<Inner>); clones share recording state, so any clone can stop() the in-progress cast.

Structs§

Video
A page video capture handle.
VideoStartOptions
Options for Video::start.