Description
Version
1.53.0-next
Steps to reproduce
- Start video recording for a page using page.video().
- Interact with the page for a significant duration (e.g., several minutes), ensuring a continuous stream of screencast frames is generated. Scenarios with slightly irregular frame intervals (due to rendering complexity or system load) might exacerbate the issue.
- Stop the recording.
- Carefully analyze the frame timestamps or playback speed of the resulting .webm file, for example, using tools like ffprobe or by observing playback.
Expected behavior
The generated video file should have an effective frame rate that is consistently very close to the target FPS (default 25 fps). The timing of events in the video should accurately reflect the real-time duration of the recording session. There should be no noticeable drift in playback speed over time.
Actual behavior
The current implementation in packages/playwright-core/src/server/chromium/videoRecorder.ts calculates the number of times to duplicate the previous frame based on the time difference between the current frame and the previous frame. Specifically, the duration timestamp - this._lastFrameTimestamp is used, and the repeat count is determined by Math.round(fps * durationSec).
This calculation introduces small rounding errors at each step. These errors accumulate over the lifetime of the recording. As a result:
- The total number of frames written to the video file might not accurately correspond to the total elapsed time according to the target FPS.
- This leads to a drift in the effective frame rate of the output video.
- The video playback speed may appear inconsistent, potentially slightly faster or slower than real-time, especially noticeable in longer recordings.
Additional context
No response
Environment
any environment