Coder Social home page Coder Social logo

Buffer about opus HOT 4 OPEN

discordjs avatar discordjs commented on June 27, 2024
Buffer

from opus.

Comments (4)

AxioDev avatar AxioDev commented on June 27, 2024 2

Up, thanks for your answer, but can you provide a code example to solve the problem ?

from opus.

mikkeldamsgaard avatar mikkeldamsgaard commented on June 27, 2024 1

You need to make sure that the length of the argument to encoder.encode() is a multiple of 2.5ms. Since you are encoding with 16000 and two channels (!) that would be multiple of 1622.5 = 80 frames that is 160 bytes. A good normal window size is 20ms, so that would make you have the data buffer at 8*160 bytes exactly.

That said, then the implementation does not check for the return value of int compressedLength = opus_encode(this->encoder, pcm, frameSize, &(this->outOpus[0]), MAX_PACKET_SIZE);. If the data buffer is not exactly aligned it returns -1 which in unsigned form is 0x100000000 and that generates the error as the code tries to allocate a buffer right after this call with the compressedLength.

from opus.

LuvbCa avatar LuvbCa commented on June 27, 2024

im currently not working on that project anymore but i will need it in the near future, so im thankful for your answer! i will close this issue when i get to try this!

from opus.

iocmet avatar iocmet commented on June 27, 2024

You need to make sure that the length of the argument to encoder.encode() is a multiple of 2.5ms. Since you are encoding with 16000 and two channels (!) that would be multiple of 16_2_2.5 = 80 frames that is 160 bytes. A good normal window size is 20ms, so that would make you have the data buffer at 8*160 bytes exactly.

That said, then the implementation does not check for the return value of int compressedLength = opus_encode(this->encoder, pcm, frameSize, &(this->outOpus[0]), MAX_PACKET_SIZE);. If the data buffer is not exactly aligned it returns -1 which in unsigned form is 0x100000000 and that generates the error as the code tries to allocate a buffer right after this call with the compressedLength.

and how i can fix it?

from opus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.