UNPKG

wibbitz-puppeteer-screen-recorder

Version:

A puppeteer Plugin that uses the native chrome devtool protocol for capturing video frame by frame. Also supports an option to follow pages that are opened by the current page object

65 lines (64 loc) 1.99 kB
import { Page } from 'puppeteer'; /** * PuppeteerScreenRecorder class is responsible for managing the video * * ```typescript * const screenRecorderOptions = { * followNewTab: true, * fps: 25, * } * const savePath = "./test/demo.webm"; * const screenRecorder = new PuppeteerScreenRecorder(page, screenRecorderOptions); * await screenRecorder.start(savePath); * // some puppeteer action or test * await screenRecorder.stop() * ``` */ export declare class PuppeteerScreenRecorder { private page; private readonly options; private cdpScreencastRecorder; private ffmpegStreamWriter; private isScreencastEnded; constructor(page: Page, options?: {}); get isReadyToAdvanceFrame(): boolean; set isReadyToAdvanceFrame(newValue: boolean); /** * @ignore */ private setupListeners; /** * @ignore */ private ensureDirectoryExists; /** * @public * @method getRecordDuration * @description return the total duration of the video recorded, * 1. if this method is called before calling the stop method, it would be return the time till it has recorded. * 2. if this method is called after stop method, it would give the total time for recording * @returns total duration of video */ getRecordDuration(): string; /** * * @public * @method start * @param savePath accepts a path string to store the video * @description Start the video capturing session * @returns PuppeteerScreenRecorder * @example * ``` * const savePath = './test/demo.webm'; //.webm is required * await recorder.start(savePath); * ``` */ start(savePath: string): Promise<PuppeteerScreenRecorder>; /** * @public * @method stop * @description stop the video capturing session * @returns indicate whether stop is completed correctly or not, true if without any error, else false. */ stop(): Promise<boolean>; }