Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kldzj/puppeteer-stream
Screen capture puppeteer pages using either CDP tools or fmmpeg's x11grab
https://github.com/kldzj/puppeteer-stream
capture ffmpeg puppeteer record screen stream x11grab
Last synced: about 1 month ago
JSON representation
Screen capture puppeteer pages using either CDP tools or fmmpeg's x11grab
- Host: GitHub
- URL: https://github.com/kldzj/puppeteer-stream
- Owner: kldzj
- Created: 2022-03-19T16:21:42.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-20T14:09:39.000Z (almost 3 years ago)
- Last Synced: 2024-10-10T15:18:13.051Z (3 months ago)
- Topics: capture, ffmpeg, puppeteer, record, screen, stream, x11grab
- Language: TypeScript
- Homepage: https://npmjs.com/@kldzj/puppeteer-stream
- Size: 28.3 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Using this package you are able to screen capture your puppeteer pages.
## Installation
To use this package a [ffmpeg](https://www.ffmpeg.org/) binary needs to be available. You can obtain it from [here](https://ffmpeg.org/download.html) or using the [ffmpeg-static](https://www.npmjs.com/package/ffmpeg-static) package.
Using yarn:
```sh-session
$ yarn add @kldzj/puppeteer-stream
```Using npm:
```sh-session
$ npm i -S @kldzj/puppeteer-stream
```## Usage
View the [examples](https://github.com/kldzj/puppeteer-stream/tree/master/examples) on how to use this package.
### Notes on using the `x11` recorder
When using the `x11` recorder it is recommended to render to a [`xvfb`](https://en.wikipedia.org/wiki/X_Window_System#Xvfb) server.
```sh-session
$ export DEBUG=puppeteer-stream:*
$ xvfb-run -s "-screen 0 1920x1080x24" yarn ts-node examples/x11.ts
```### Code
```typescript
const browser = await puppeteer.launch();
const page = await browser.newPage();// https://github.com/puppeteer/puppeteer/issues/6904
const streamer = new PuppeteerStreamer(page as unknown as Page, {
// ffmpegPath: '/path/to/ffmpeg',
output: {
format: 'mp4',
path: join(process.cwd(), 'output.mp4'),
},
frameSize: {
width: 1280,
height: 720,
},
fps: 30,
});// navigate page
await page.goto('https://example.com');// start recording
await streamer.start();// do something
await page.waitFor(1000);// stop recording
await streamer.stop();// finish up
await browser.close();
```