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);