Skip to content

feat(video): allow recording video at a custom fps - #42752

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:video-fps
Sep 17, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:video-fps

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

Summary

  • New fps option for page.screencast.start(), recordVideo (recordVideoFps in other languages), test runner video and CLI/MCP video-start.
  • VP8 bitrate and encoder threads scale with pixel rate relative to 800x450@25fps; default recordings keep -b:v 1M -threads 1.
  • Screencast frames are locked to consecutive output slots, since Chromium timestamps frames on delivery rather than render (https://issues.chromium.org/issues/562567707). Without it, 1080p60 recordings duplicated and skipped ~4% of frames.
  • Firefox and WebKit still capture at most 25 fps.

// 1920x1080 at 60fps -> scale 13.8, bitrate 13824k, 4 threads
const pixelRateScale = Math.max(1, w * h * this._fps / (800 * 450 * kDefaultFps));
const bitrate = Math.round(pixelRateScale * 1000);
const threads = Math.min(8, Math.ceil(pixelRateScale / 4));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's trust ffmpeg's auto mode in case we allow >1 thread?

"-threads 0 or -threads auto means “choose automatically”; the generic codec option defaults to auto. Current ffmpeg also explicitly sets thread_count = 0 when you haven’t supplied a threads option."

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

- `fps` option for `page.screencast.start()`, `recordVideo`, test runner `video` and `video-start`
- scale vp8 bitrate and encoder threads with the pixel rate
- lock screencast frames to consecutive output slots to absorb Chromium timestamp jitter
  (https://issues.chromium.org/issues/562567707)
width: z.number().describe('Video width'),
height: z.number().describe('Video height'),
}).optional().describe('Video size'),
fps: z.number().optional().describe('Video frame rate in frames per second, defaults to 25'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be z.number().int().positive().optional()?

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [chrome] › mcp/annotate.spec.ts:173 › user-initiated annotate downloads zip with feedback.md @mcp-windows-latest-chrome
❌ [firefox] › mcp/annotate.spec.ts:417 › should cancel browser_annotate when the MCP client disconnects @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-session.spec.ts:54 › idle timeout shuts the session down @mcp-windows-latest-firefox

8587 passed, 1446 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

2 failed
❌ [installation tests] › playwright-cdn.spec.ts:43 › playwright cdn failover should work (https://cdn.playwright.dev/dbazure/download/playwright) @package-installations-macos-latest
❌ [installation tests] › playwright-cdn.spec.ts:43 › playwright cdn failover should work (https://playwright.download.prss.microsoft.com/dbazure/download/playwright) @package-installations-macos-latest

5 flaky ⚠️ [chromium-library] › library/video.spec.ts:725 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-arm-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-event-request.spec.ts:181 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node20`

51973 passed, 1247 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 All three failures are pre-existing flakes — the PR is clear

Hi, I'm the Playwright bot and I took a look at the failing CI on this PR.

All three failures are Windows-only MCP tests that each fail with the same error on SHAs and PRs unrelated to this one. Nothing here points at the fps change.

Details

Overall: the PR touches video/screencast encoding (videoRecorder.ts, screencast.ts, protocol fps plumbing). The three failures are MCP annotate/session tests that don't record video, and each has a failure history predating this PR. The only video-adjacent signal in this PR's CI, library/video.spec.ts:690 › screencast › should capture full viewport, was flaky (passed on retry), not failed.

Pre-existing flake / infra

Evidence comes from the aggregated CI results database, topped up through this PR's run.

Triaged by the Playwright bot - agent run

@github-actions

Copy link
Copy Markdown
Contributor

🟢 All five failures are pre-existing flakes — the PR looks clear

Hi, I'm the Playwright bot and I triaged the red CI here. None of the failing tests touch video, screencast, or fps; each one fails with the same error on other PRs and on main, one of them on this PR's own base commit bf9d04f2.

Details

The PR changes video/screencast recording (videoRecorder.ts, browserContext.ts, pageDispatcher.ts, tools/backend/video.ts, cli-daemon/commands.ts) plus docs and generated types. The failures are in MCP annotate, MCP CLI session listing, and the installation CDN suite — none of which record video. Counts below are from the aggregated CI results DB, grouped by (project_name, file, test_title) on the same bot.

Pre-existing flake / infra

Nothing to fix here; a rerun should be green, modulo the cli-session flake's 1-in-3 odds.

Triaged by the Playwright bot - agent run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants