#2195

record: frames after the first are blurry at device scale factor 2 (screencast captured at layout size and scaled up)

Openeko24iveopened 8d ago

Problem

Recordings made at a device scale factor above 1 are sharp only in the first frame. Every later frame is blurry.

On agent-browser 0.39.1 (macOS arm64, Chrome for Testing 155):

agent-browser set viewport 1440 900 2
agent-browser open <page>
agent-browser record start /tmp/out.mp4 --fps 60 --cursor
agent-browser mouse move 400 450 --human --duration 800
agent-browser record stop

The output is 2880x1800. Frame 0 is crisp, and every later frame looks like a 1440x900 image scaled up to 2880x1800: soft text and smeared icons. On a static area of the page, later frames score about 30 dB PSNR against frame 0.

Cause

The first frame comes from Page.captureScreenshot, which returns device pixels. Later frames come from Page.startScreencast, which is started without maxWidth/maxHeight (recording.rs#L1503). Chrome then sends frames at the viewport's layout size, and ffmpeg scales them up to the size of the first frame.

To rule out compression, I re-ran with ffmpeg forced to lossless (-qp 0). The blur stays the same, so it comes from the screencast frames, not the encoder.

At scale 1 every frame matches, but a 1x recording looks soft on HiDPI screens, so 2x is what you want for demo videos.

A smaller, separate issue: MP4 output always uses -preset ultrafast with x264's default CRF 23 (recording.rs#L731), which visibly softens UI text in later frames, and there's no flag to change it.

Suggested fix

  • Pass maxWidth/maxHeight as the viewport size multiplied by the device scale factor when starting the screencast, so frames arrive at device-pixel resolution.
  • Optionally, expose encoder quality (for example record start --quality <crf>), or use a lower default CRF for MP4.

Related: #1207 (recording resolution).

I can put up a PR for this if that's helpful.

Activity

0

No activity yet.