abalabahaha / opusscript

JS bindings for libopus 1.4, ported with Emscripten
MIT License
62 stars 18 forks source link

RangeError: offset is out of bounds #22

Open LeGeek01 opened 2 years ago

LeGeek01 commented 2 years ago

Hello, I have an error when my bot play a song in a voice channel.

RangeError: offset is out of bounds
at Uint8Array.set ()
at OpusScript.decode (/home/LeGeek01/SecretHeberg-Musique/node_modules/opusscript/index.js:78:17)
at Decoder._decode (/home/LeGeek01/SecretHeberg-Musique/node_modules/prism-media/src/opus/Opus.js:64:25)
at Decoder._transform (/home/LeGeek01/SecretHeberg-Musique/node_modules/prism-media/src/opus/Opus.js:204:22)
at Decoder.Transform._write (node:internal/streams/transform:184:23)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at Decoder.Writable.write (node:internal/streams/writable:334:10)
at PassThrough.ondata (node:internal/streams/readable:749:22)
at PassThrough.emit (node:events:394:28)

I have :

ytdl-core@4.9.1
prism-media@1.3.2
opusscript@0.0.8
discord.js@12.5.3
nodejs@16.6.1

Thanks in advance for answers.

Gamer08YT commented 1 year ago

Same Problem

LeGeek01 commented 1 year ago

I fix that by deleting the "type" or "mode" option, I don't remember because it was a year ago... I know this variable was equal to "opus"

fox3000foxy commented 1 year ago

Can u provide the code ?

fox3000foxy commented 1 year ago

The code that fix this issue

seyicoded commented 8 months ago

any fix on this yet

xiangyuecn commented 8 months ago

Modify MAX_FRAME_SIZE = 48000 * 60 / 1000 to *`MAX_FRAME_SIZE = 960 6** in **index.js`**, supports up to 120ms per frame

https://github.com/abalabahaha/opusscript/blob/07ae74db7385d6d1be981d929f2f2f2b7e6b8449/index.js#L21-L25

https://github.com/abalabahaha/opusscript/blob/07ae74db7385d6d1be981d929f2f2f2b7e6b8449/src/opusscript_encoder.cpp#L5-L9