From 4d0a02b4518252ac434714552cffc5173387ac0a Mon Sep 17 00:00:00 2001 From: Vinlic Date: Fri, 8 Dec 2023 09:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8pagePrepareFn?= =?UTF-8?q?=E4=B8=AD=E8=AE=BE=E7=BD=AE=E8=A7=86=E9=A2=91=E7=9A=84duration?= =?UTF-8?q?=E3=80=81startTime=E3=80=81fps=E7=AD=89=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/ChunkVideo.js | 8 ++++---- api/SingleVideo.js | 8 ++++---- core/Synthesizer.js | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api/ChunkVideo.js b/api/ChunkVideo.js index 175eb4a..af9fb2a 100644 --- a/api/ChunkVideo.js +++ b/api/ChunkVideo.js @@ -154,7 +154,7 @@ export default class ChunkVideo extends VideoChunk { async #synthesize() { const page = await this.#acquirePage(); try { - const { url, content, width, height, fps, startTime, duration, pageWaitForOptions, pageViewport = {} } = this; + const { url, content, width, height, pageWaitForOptions, pageViewport = {} } = this; // 监听页面实例发生的某些内部错误 page.on("error", err => this._emitError("Page error:\n" + err.stack)); // 监听页面是否崩溃,当内存不足或过载时可能会崩溃 @@ -207,9 +207,9 @@ export default class ChunkVideo extends VideoChunk { page.on("frame", buffer => this.input(buffer)); // 启动捕获 await page.startScreencast({ - fps, - startTime, - duration, + fps: this.fps, + startTime: this.startTime, + duration: this.duration, autostart: this.autostartRender }); // 监听并等待录制完成 diff --git a/api/SingleVideo.js b/api/SingleVideo.js index d6124f1..0d886be 100644 --- a/api/SingleVideo.js +++ b/api/SingleVideo.js @@ -151,7 +151,7 @@ export default class SingleVideo extends Synthesizer { async #synthesize() { const page = await this.#acquirePage(); try { - const { url, content, width, height, fps, startTime, duration, pageWaitForOptions, pageViewport = {} } = this; + const { url, content, width, height, pageWaitForOptions, pageViewport = {} } = this; // 监听页面实例发生的某些内部错误 page.on("error", err => this._emitError("Page error:\n" + err.stack)); // 监听页面是否崩溃,当内存不足或过载时可能会崩溃 @@ -199,9 +199,9 @@ export default class SingleVideo extends Synthesizer { page.on("frame", buffer => this.input(buffer)); // 启动捕获 await page.startScreencast({ - fps, - startTime, - duration, + fps: this.fps, + startTime: this.startTime, + duration: this.duration, autostart: this.autostartRender }); // 监听并等待录制完成 diff --git a/core/Synthesizer.js b/core/Synthesizer.js index 21e3484..cbbc99d 100644 --- a/core/Synthesizer.js +++ b/core/Synthesizer.js @@ -214,6 +214,7 @@ export default class Synthesizer extends EventEmitter { assert(this.isReady(), "Synthesizer status is not READY, please reset the synthesizer: synthesizer.reset()"); this.#setState(Synthesizer.STATE.SYNTHESIZING); this._startupTime = _.defaultTo(this._startupTime, performance.now()); + this._targetFrameCount = util.durationToFrameCount(this.duration, this.fps); (async () => { await fs.ensureDir(path.dirname(this.outputPath)); await fs.ensureDir(this.tmpDirPath);