# playwright-video

> Capture a video of a Playwright page

Latest version **2.4.0** (published 2020-09-23) · BSD-3-Clause-Clear license · 0 weekly downloads

## Install

```sh
npm install playwright-video
pnpm add playwright-video
yarn add playwright-video
bun add playwright-video
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.0 |
| Published | 2020-09-23 |
| First published | 2020-02-28 |
| Weekly downloads | 0 |
| License | BSD-3-Clause-Clear |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.15.0 |
| Dependencies | 5 |
| Unpacked size | 53.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 199 |
| Author | QA Wolf |
| Maintainers | jperl, flaurida |

## Links

- npm: https://www.npmjs.com/package/playwright-video
- Repository: https://github.com/qawolf/playwright-video
- Homepage: https://github.com/qawolf/playwright-video#readme
- Issues: https://github.com/qawolf/playwright-video/issues
- npm.io page: https://npm.io/package/playwright-video

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) *
- [tslib](https://npm.io/package/tslib.md) ^2.0.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [fluent-ffmpeg](https://npm.io/package/fluent-ffmpeg.md) ^2.1.2
- [playwright-core](https://npm.io/package/playwright-core.md) ^1.4.1

## Recent versions

- 2.4.0 (latest) — 2020-09-23
- 2.3.1 — 2020-08-02
- 2.3.0 — 2020-07-07
- 2.2.0 — 2020-06-10
- 2.1.0 — 2020-06-07
- 2.0.0 — 2020-06-02
- 1.0.2 — 2020-05-29
- 1.0.1 — 2020-05-29
- 1.0.0 — 2020-05-06
- 0.13.0 — 2020-04-09
- 0.12.0 — 2020-03-24
- 0.7.0 — 2020-03-19
- 0.6.0 — 2020-03-18
- 0.5.0 — 2020-03-11
- 0.4.0 — 2020-03-09
- … 8 more at https://npm.io/package/playwright-video/versions

## README

# playwright-video

[![npm version](https://badge.fury.io/js/playwright-video.svg)](https://badge.fury.io/js/playwright-video) ![Unit Tests](https://github.com/qawolf/playwright-video/workflows/Unit%20Tests/badge.svg)

🎬 Save a video recording of a [Playwright](https://github.com/microsoft/playwright) page (Chromium only for now)

When Playwright adds support for the Screencast API in Firefox and WebKit, this will be updated to support these browsers.

## Install

```sh
npm i playwright playwright-video @ffmpeg-installer/ffmpeg
```

If you already have [FFmpeg](https://www.ffmpeg.org) installed, you can skip the `@ffmpeg-installer/ffmpeg` installation by setting the `FFMPEG_PATH` environment variable.

```sh
npm i playwright playwright-video
```

## Use

```js
const { chromium } = require('playwright');
const { saveVideo } = require('playwright-video');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext();
  const page = await context.newPage();

  await saveVideo(page, '/tmp/video.mp4');
  await page.goto('http://example.org');
  await page.click('a');

  await browser.close();
})();
```

The video will be saved at the specified `savePath` (`/tmp/video.mp4` in the above example).

## API

#### playwright-video.saveVideo(page, savePath[, options])

- `page` <[Page]> Save a video of this page. Only supports Chromium for now.
- `savePath` <[string]> Where to save the video.
- `options` <[Object]>
  - `followPopups` <[boolean]> Whether or not to follow browser focus when popups are opened. Defaults to `false`. Note: this option will only work correctly if the popups opened are the same size as the original page. If a smaller or larger popup is open, frames will be scaled to fit the original size.
  - `fps` <[number]> The frames per second for the recording. Defaults to `25`. A higher number will improve the recording quality but also increase the file size.
- returns: <[Promise]<[PageVideoCapture](#class-pagevideocapture)>>

Records video of a page and saves it at the specified path.

```js
await saveVideo(page, '/tmp/video.mp4');
```

### class: PageVideoCapture

A `PageVideoCapture` is created when you call `saveVideo`. It manages capturing the video of your page and saving it.

### pageVideoCapture.stop()

- returns <[Promise]>

Stop the video capture if needed and save the video. The returned `Promise` resolves when the video is saved.

The video capture will be stopped automatically if you close the page, so you should not need to call this unless you want to explicitly wait until the video is saved.

```js
const capture = await saveVideo(page, '/tmp/video.mp4');
await capture.stop();
```

[object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object 'Object'
[page]: https://github.com/microsoft/playwright/blob/master/docs/api.md#class-page 'Page'
[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise 'Promise'
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type 'string'

---
_Source: https://npm.io/package/playwright-video · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
