webm-duration-fix icon indicating copy to clipboard operation
webm-duration-fix copied to clipboard

RangeError: The value of "byteLength" is out of range.

Open maphstr opened this issue 2 years ago • 3 comments

Hi i'm using this module in electron and everything works fine after until i've built the app with electron-builder Then I get this error:

RangeError: The value of "byteLength" is out of range. It must be >= 1 and at __node_internal_captureLargerStackTrace (node:internal/errors:464:5) at new NodeError (node:internal/errors:371:5) at boundsError (node:internal/buffer:86:9) at Buffer.readUIntBE (node:internal/buffer:273:3) at w.readContent (main.c1a754a1e0df31f1.js:1:307044) at w.readChunk (main.c1a754a1e0df31f1.js:1:305350) at w.decode (main.c1a754a1e0df31f1.js:1:305037) at main.c1a754a1e0df31f1.js:1:375265 at F (main.c1a754a1e0df31f1.js:1:374710) at Object.next (main.c1a754a1e0df31f1.js:1:374817) at I (main.c1a754a1e0df31f1.js:1:373505) at v.invoke (polyfills.ffcb200af55b2a7d.js:1:6543) at Object.onInvoke (main.c1a754a1e0df31f1.js:1:1495746) at v.invoke (polyfills.ffcb200af55b2a7d.js:1:6483) at M.run (polyfills.ffcb200af55b2a7d.js:1:1939) at polyfills.ffcb200af55b2a7d.js:1:16777 at v.invokeTask (polyfills.ffcb200af55b2a7d.js:1:7161) at Object.onInvokeTask (main.c1a754a1e0df31f1.js:1:1495559) at v.invokeTask (polyfills.ffcb200af55b2a7d.js:1:7082) at M.runTask (polyfills.ffcb200af55b2a7d.js:1:2556) at _ (polyfills.ffcb200af55b2a7d.js:1:9176)

Anyone know whats going on here?

maphstr avatar Nov 29 '22 12:11 maphstr

You can refer to this demo for usage

Or provide the specific version you are using

buynao avatar Dec 02 '22 03:12 buynao

我也碰到这个问题了,我是把录像直接保存到文件了,然后录制完成后再通过这个工具进行修复,但报错了。

const fixDuration = async (filePath: string): Promise<Blob> => {
    return new Promise((resolve, reject) => {
        // 读取视频文件内容
        const buf = fs.readFileSync(filePath);//读取文件,并将缓存区进行转换
        const uint8Buffer = Uint8Array.from(buf);
        const blob = new Blob([uint8Buffer],{type:'video/mp4'});
        console.log("转换后", blob)

        fixWebmDuration(blob).then((blob) => {
            log.log('修复webm文件时长成功')
            //将Blob文件流写入文件
            saveBlob(blob).then(res => {
                let stream = fs.createWriteStream(filePath, {mode: 777, flags: 'w', autoClose: true});
                stream.write(res);
                stream.end();
            })
            resolve(blob)
        }).catch((e) => {
            log.error('修复webm文件时长失败:%s', e)
            reject(e)
        })

    })
}

lizhen789 avatar Apr 06 '23 12:04 lizhen789

Same for me, excepting that I'm getting this both in development and in release build. Electron 22.3.3.

Skyggedans avatar Apr 25 '23 08:04 Skyggedans