Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement screencasting #11084

Merged
merged 1 commit into from Oct 6, 2023
Merged

feat: implement screencasting #11084

merged 1 commit into from Oct 6, 2023

Conversation

jrandolf
Copy link
Contributor

@jrandolf jrandolf commented Oct 6, 2023

Summary

Screencasting is a new, experimental feature that allows users to record their flows as that run!

This requires ffmpeg to be installed where you run Puppeteer.

Example

import puppeteer from 'puppeteer';

// Launch a browser
const browser = await puppeteer.launch();

// Create a new page
const page = await browser.newPage();

// Go to your site.
await page.goto("https://www.example.com");

// Start recording.
const recorder = await page.screencast({path: 'recording.webm'});

// Do something.

// Stop recording.
await recorder.stop();

browser.close();

You can also stream the recorder to somewhere else!

import fs from 'fs';
import puppeteer from 'puppeteer';

// Launch a browser
const browser = await puppeteer.launch();

// Create a new page
const page = await browser.newPage();

// Go to your site.
await page.goto("https://www.example.com");

// Start recording.
const recorder = await page.screencast();

// Piping into /dev/null for illustrative purposes.
recorder.pipe(fs.createWriteStream('/dev/null'));

// Do something.

// Stop recording.
await recorder.stop();

browser.close();

Options

For now, we have three options:

  • crop - Specifies the region of the viewport to crop.
  • scale - Scales the output video. For example, 0.5 will shrink the width and height of the output video by half. 2 will double the width and height of the output video.
  • path - Specifies a .webm file path to save the recording to.
  • speed - Specifies the speed to record at. For example, 0.5 will slowdown the video by 50%. 2 will double the speed of the output video.

Fixed: #478

@jrandolf jrandolf requested a review from OrKoN October 6, 2023 02:24
@jrandolf jrandolf removed the request for review from OrKoN October 6, 2023 03:35
@jrandolf jrandolf marked this pull request as draft October 6, 2023 03:35
@jrandolf jrandolf force-pushed the jrandolf/screenshots branch 2 times, most recently from d0d3b9f to bffa674 Compare October 6, 2023 03:39
@jrandolf jrandolf requested a review from OrKoN October 6, 2023 05:45
@jrandolf jrandolf force-pushed the jrandolf/screenshots branch 3 times, most recently from a8722e5 to d516ae4 Compare October 6, 2023 05:49
@jrandolf jrandolf marked this pull request as ready for review October 6, 2023 05:49
@OrKoN
Copy link
Collaborator

OrKoN commented Oct 6, 2023

@jrandolf could you please rebase?

@jrandolf jrandolf force-pushed the jrandolf/screenshots branch 5 times, most recently from ab2c733 to b204984 Compare October 6, 2023 06:45
test/src/screencast.spec.ts Outdated Show resolved Hide resolved
@jrandolf jrandolf force-pushed the jrandolf/screenshots branch 5 times, most recently from 2ae9306 to 2cc13fe Compare October 6, 2023 08:15
@jrandolf jrandolf requested a review from OrKoN October 6, 2023 08:17
@jrandolf jrandolf force-pushed the jrandolf/screenshots branch 2 times, most recently from 87c6390 to 33f0d4e Compare October 6, 2023 08:27
Copy link
Collaborator

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

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

LGTM

@jrandolf jrandolf enabled auto-merge (squash) October 6, 2023 08:42
@jrandolf jrandolf force-pushed the jrandolf/screenshots branch 4 times, most recently from 69de1ab to 8e0c2ce Compare October 6, 2023 09:09
@jrandolf jrandolf disabled auto-merge October 6, 2023 14:34
@jrandolf jrandolf merged commit f060d46 into main Oct 6, 2023
48 of 55 checks passed
@jrandolf jrandolf deleted the jrandolf/screenshots branch October 6, 2023 14:50
@release-please release-please bot mentioned this pull request Oct 6, 2023
} = roundRectangle(normalizeRectangle(options.crop));
if (x < 0 || y < 0) {
throw new Error(
`\`crop.x\` and \`crop.x\` must be greater than or equal to 0.`
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the scond one should be crop.y ?

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.

startScreencast feature?
3 participants