Skip to content

Commit a25ea08

Browse files
committed
docs: update screencast
1 parent 2cd5a20 commit a25ea08

File tree

5 files changed

+26
-54
lines changed

5 files changed

+26
-54
lines changed

README.md

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -864,76 +864,48 @@ This setting will change the default maximum navigation time.
864864

865865
### screencast
866866

867-
The [`@browserless/screencast`](https://npm.im/@browserless/screencast) package allows you to automate browser action and produce a video recording as output.
867+
The [`@browserless/screencast`](https://npm.im/@browserless/screencast) package allows you to capture each frame of a browser navigation using puppeteer.
868868

869869
<div style="margin: auto;">
870-
<video poster="/static/screencast.png" loop="" controls="" src="https://github.com/microlinkhq/browserless/assets/2096101/81d3e7e2-bf12-4ce1-8d54-f7c36ce0b2c9" style="width: 100%;border-radius: 4px;" autoplay=""></video>
870+
<video poster="/static/screencast.png" loop="" controls="" src="https://github.com/microlinkhq/browserless/assets/2096101/a1753a2f-d4bb-47f1-a457-a0b73bb9d65d" style="width: 100%;border-radius: 4px;" autoplay=""></video>
871871
</div>
872872

873-
```js
874-
const screencast = require('@browserless/screencast')
875-
876-
const buffer = await screencast({
877-
getBrowserless: () => browserless,
878-
format: 'webm',
879-
ffmpegPath: await execa.command('which ffmpeg').then(({ stdout }) => stdout),
880-
gotoOpts: {
881-
url: 'https://vercel.com',
882-
animations: true,
883-
abortTypes: [],
884-
waitUntil: 'load'
885-
},
886-
withPage: async page => {
887-
await page.waitForTimeout(7000)
888-
}
889-
})
890-
```
873+
This API is similar to [screenshots](#screenshoturl-options), but you have a more granular control over the frame and the output:
891874

892-
#### options
893-
894-
##### ffmpegPath
895-
896-
type: `string`
875+
```js
876+
const createScreencast = require('@browserless/screencast')
877+
const createBrowser = require('browserless')
897878

898-
The path for using `ffmpeg` binary.
879+
const browser = createBrowser()
880+
const browserless = await browser.createContext()
881+
const page = await browserless.page()
899882

900-
##### format
883+
const screencast = createScreencast(page, {
884+
maxWidth: 1280,
885+
maxHeight: 800
886+
})
901887

902-
type: `string`</br>
903-
values: `'mp4'` | `'gif' | 'webm'`</br>
904-
default: `'webm'`
888+
const frames = []
889+
screencast.onFrame(data => frames.push(data))
905890

906-
The video output format.
891+
screencast.start()
892+
await browserless.goto(page, { url, waitForTimeout: 300 })
893+
await screencast.stop()
907894

908-
##### frames
895+
console.log(frames)
896+
```
909897

910-
These options will be passed to [Page.startScreencast](https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-startScreencast)
898+
Check a [full example](/blob/master/packages/screencast/examples/server.js) generating a GIF as output.
911899

912-
##### gotoOpts
900+
#### page
913901

914902
type: `object`
915903

916-
These options will be passed to [goto[#options](/#options-6) to resolve, before starting the recording.
917-
918-
##### timeout
919-
920-
type: `number`</br>
921-
default: `30000`
922-
923-
Sets the maximum navigation time.
924-
925-
##### tmpPath
926-
927-
type: `string`</br>
928-
default: `os.tmpdir()`
904+
The [Page](https://pptr.dev/api/puppeteer.page) object.
929905

930-
The temporary directory for writing the video. This is necessary for ffmpeg, and will be cleaned up before the function is finished.
931-
932-
##### withPage(page)
933-
934-
type: `function`
906+
#### options
935907

936-
It sets the in-page browser action to perform during the video recording.
908+
See [Page.startScreencast](https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-startScreencast) to know all the options and values supported.
937909

938910
## Packages
939911

packages/screencast/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@browserless/screencast",
3-
"description": "Browserless video recording using puppeteer.",
3+
"description": "Browserless frame capturing using puppeteer",
44
"homepage": "https://browserless.js.org/#/?id=screencasturl-options",
55
"version": "10.3.0",
66
"main": "src/index.js",

static/screencast.mp4

626 KB
Binary file not shown.

static/screencast.png

1.2 MB
Loading

static/screencast.webm

-990 KB
Binary file not shown.

0 commit comments

Comments
 (0)