amishshah / prism-media

Easily transcode media using Node.js 🎶
https://amishshah.github.io/prism-media
Apache License 2.0
241 stars 55 forks source link

The value of "sourceEnd" is out of range error in 2.0.0-alpha.0 #104

Closed tony-ist closed 1 year ago

tony-ist commented 2 years ago

Issue:

RangeError [ERR_OUT_OF_RANGE]: The value of "sourceEnd" is out of range. It must be >= 0 && <= 3. Received 8 
  at validateOffset (node:buffer:113:3)
  at Buffer.compare (node:buffer:895:5) 
  at Decoder._transform (/Users/tony/Projects/aoede-bot/node_modules/prism-media/src/opus/Decoder.ts:23:13)
  ...

I get the aforementioned error when working with opus.Decoder from prism-media version 2.0.0-alpha.0. It originates there at chunk.compare call. I guess it is because of a small chunk with a length of 3. Any ideas how to fix?

Steps to reproduce:

const listenStream = connection.receiver.subscribe(userId, {
  end: {
    behavior: EndBehaviorType.AfterSilence,
    duration: 1000,
  },
})

const opusDecoder = new prism.opus.Decoder({
  frameSize: 960,
  channels: 1,
  rate: 48000,
})

inputStream.pipe(opusDecoder)

Further details:

dcapape commented 2 years ago

I'm having exactly the same issue with the same code