Package Exports
- puppeteer-screen-recorder
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (puppeteer-screen-recorder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
puppeteer-screen-recorder
A puppeteer Plugin which uses the native chrome devtool protocol for capturing screen and record video frame by frame. Also support option to follow pages which are opened by the current page object.
Key Feature
1. Follow Page Automatically
Automatically follows pages (multiple pages) which are opened at runtime, which is part of video capturing. Also support options to disable the default flow.
2. No overhead over FF_MPEG library
FFMPEG installation configuration and it configuration are automatically managed by the library itself. But options is available to pointing the preinstalled one.
3. Native Implementation
This plugin works directly with native chrome devtool protocol to capture the video under the wood.
4. Adopted the Chromium principles
Adopted Chromium principles such as Speed, Security, Stability and Simplicity. It also ensures no frames are missed during video capturing and doesn't impact the performance, since its doesn't use any other puppeteer plugin internally.
Getting Started
Installation Guide
Using Npm
npm install puppeteer-screen-recorderUsing Yarn
yarn add puppeteer-screen-recorderAPI Description
1. Import the plugin using ES6 or commonjs.
// ES6
import { PuppeteerScreenRecorder } from 'puppeteer-screen-recorder';
// or commonjs
const PuppeteerScreenRecorder = require('puppeteer-screen-recorder');2. Setup the Configuration object.
const Config = {
followNewTab: true,
fps: 25,
ffmpeg_Path: '<path of ffmpeg_path>',
};
- followNewTab : Boolean value which is indicate whether to follow the tab or not. Default value is true.
- fps: Numeric value which state no.of Frames per second in which the video should be recorded. default value is 25.
- ffmpeg_Path: String value pointing to the installation of FFMPEG. Default is null (Automatically install the FFMPEG and use it).
3. create a new instance of video recording
const recorder = PuppeteerScreenRecorder(page, Config)
- page: Puppeteer page object which needs to captured.
- config: Config is an optional object. Default value is
{followNewTab: true, fps: 25, ffmpeg_Path: null }
4. Start Video capturing
await recorder.start(savePath);savePath: string value indicating the directory on where to save the video.
5. Stop the video capturing.
await recorder.stop();Example
const puppeteer = require('puppeteer');
const PuppeteerScreenRecorder = require('puppeteer-screen-recorder');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const recorder = new PuppeteerScreenRecorder(page);
await recorder.start('./report/video/');
await page.goto('https://example.com');
await page.goto('https://test.com');
await recorder.stop();
await browser.close();
})();FAQ
Some of the frequently asked question about puppeteer screen recording are
Q: Does it support Chrome in headless mode?
Yes, it supports Both headless and headFul mode.
It records full length video, frame by frame even when Chrome runs in headless mode.
Q: Does it use the window object?
No, it's not tied to the window Object.
Q: Does it follows pages which are opened at runtime
Yes, it automatically follows pages which is created at runtime.
Q: is there an option to disable video recording for new page created and record video only for the page object passed
Yes, By setting the options.followNewTab to false, it record only video for the passed page object alone.
Q: Does it support to record video at 60 fps
Yes, video can be recorded at 60 fps. By setting options.fps to 60.
Q:Does it use the window object?
No, it doesn't use the window object.
Q: Does it use FFMPEG internally?
Yes, it uses FFMPEG with optimized options to speed up the video recording using stream from chrome devtool protocol.