Implementation:Microsoft Playwright Screencast
Overview
Screencast manages page screencast capture and video recording, coordinating between browser screencast frames and the FFmpeg-based video recorder with intelligent frame throttling.
Description
The Screencast class handles two responsibilities:
1. Video recording -- Starts and stops VideoRecorder instances to capture page content as WebM video files
2. Frame throttling -- Uses the internal FrameThrottler class to control frame rate, aiming at 25fps for video recording and 5fps for tracing, with burst capability around user actions
The throttler maintains a "recharge" mechanism that allows temporary bursts of high-framerate capture around user interactions, then settles back to a lower rate for background recording.
Usage
Created internally per page when video recording or tracing with screenshots is enabled.
Code Reference
Source Location
packages/playwright-core/src/server/screencast.ts (224 lines)
Class Signature
export class Screencast {
constructor(page: Page)
stopFrameThrottler(): void
setOptions(options: { width: number; height: number; quality: number } | null): void
throttleFrameAck(ack: () => void): void
temporarilyDisableThrottling(): void
async startVideoRecording(options: types.VideoOptions): Promise<void>
async stopVideoRecording(): Promise<void>
}
Import
import { Screencast } from './server/screencast';
I/O Contract
Inputs
page: Page-- the page to capture- Video options: output file path, width, height
- Screencast options: width, height, quality
Outputs
- WebM video files written to disk via
VideoRecorder - Frame throttling callbacks for tracing integration
Related Pages
- Microsoft_Playwright_VideoRecorder -- FFmpeg-based video recording