From 35a14b1143c1ab6557cc219a490f81390fac2401 Mon Sep 17 00:00:00 2001 From: Prasana Date: Sun, 18 Feb 2024 16:41:39 +0000 Subject: [PATCH] Fix the fix and formatting the pull request --- src/lib/pageVideoStreamTypes.ts | 5 +++-- src/lib/pageVideoStreamWriter.ts | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/pageVideoStreamTypes.ts b/src/lib/pageVideoStreamTypes.ts index 06cc013..2584b85 100644 --- a/src/lib/pageVideoStreamTypes.ts +++ b/src/lib/pageVideoStreamTypes.ts @@ -117,7 +117,8 @@ export type PuppeteerScreenRecorderOptions = { /** * @name ffmpegAdditionalOptions * @member PuppeteerScreenRecorderOptions - * @description Allows you to pass additional options to the ffmpeg encoder - for example you might want to pass "-movflags +faststart" + * @description Allows you to pass additional options to the ffmpeg encoder - + * @example you might want to pass "-movflags +faststart" */ readonly ffmpegAdditionalOptions?: string[]; @@ -142,7 +143,7 @@ export type PuppeteerScreenRecorderOptions = { * @member PuppeteerScreenRecorderOptions * @description Specify metadata information as key value pairs. */ - readonly metadata?: object + readonly metadata?: Record; }; /** @ignore */ diff --git a/src/lib/pageVideoStreamWriter.ts b/src/lib/pageVideoStreamWriter.ts index 7738c08..f12568e 100644 --- a/src/lib/pageVideoStreamWriter.ts +++ b/src/lib/pageVideoStreamWriter.ts @@ -210,8 +210,11 @@ export default class PageVideoStreamWriter extends EventEmitter { .on('progress', (progressDetails) => { this.duration = progressDetails.timemark; }); - for(const key in this.options.metadata) { - outputStream.outputOptions('-metadata', `${key}=${this.options.metadata[key]}`); + for (const key in this.options.metadata) { + outputStream.outputOptions( + '-metadata', + `${key}=${this.options.metadata[key]}` + ); } if (this.options.recordDurationLimit) { @@ -309,29 +312,25 @@ export default class PageVideoStreamWriter extends EventEmitter { public write(data: Buffer, durationSeconds = 1): void { this.status = VIDEO_WRITE_STATUS.IN_PROGRESS; - const totalFrames = durationSeconds * this.options.fps; - let floored = Math.floor(totalFrames); + const totalFrames = durationSeconds * this.options.fps; + const floored = Math.floor(totalFrames); - let numberOfFPS = Math.max( - floored, - 1 - ); + let numberOfFPS = Math.max(floored, 1); if (floored === 0) { this.frameGain += 1 - totalFrames; } else { this.frameLoss += totalFrames - floored; } - while(1 < this.frameLoss) { + while (1 < this.frameLoss) { this.frameLoss--; numberOfFPS++; } - while(1 < this.frameGain) { + while (1 < this.frameGain) { this.frameGain--; numberOfFPS--; } - for (let i = 0; i < numberOfFPS; i++) { this.videoMediatorStream.write(data); }