Skip to content

Commit

Permalink
Fix the fix and formatting the pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanaworld committed Feb 18, 2024
1 parent c5982d7 commit 35a14b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/lib/pageVideoStreamTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand All @@ -142,7 +143,7 @@ export type PuppeteerScreenRecorderOptions = {
* @member PuppeteerScreenRecorderOptions
* @description Specify metadata information as key value pairs.
*/
readonly metadata?: object
readonly metadata?: Record<string, string>;
};

/** @ignore */
Expand Down
21 changes: 10 additions & 11 deletions src/lib/pageVideoStreamWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 35a14b1

Please sign in to comment.