Closed richdunajewski closed 4 years ago
The node-opus
package shouldn't be more than a simple binding on top of the native http://opus-codec.org/
You might want to look at the Opus decoder/encoder APIs and how they deal with the bitrates.
It sounds like the target bitrate of each frame can vary, assuming the sending application knows to back off and lower the rate (sounds like it's out of band info, not handled automatically for you). In that case, if using the stream, there doesn't seem to be a way to modify the bitrate. You'd have to establish a new stream without breaking anything and I'm not aware of a way to do that. You'd interrupt the pipeline that goes to the ogg encoder.
Now if you're encoding to a buffer, you may be able to modify the target bitrate on the fly and the subsequent frames will be at the lower bitrate. The part that isn't clear is how the decoder handles a sudden change in bitrate without the user hearing a sharp drop in audio bandwidth. Opus advertises that they handle this but it's hard to figure out what's going on even with the spec. Does it blend the audio to avoid the sharp transition or do you have to softly change the rate to avoid it.
I got the basics working but now I want to put it to the test and handle any kind of network conditions. Full band audio with a graceful fallback to narrow band as the network conditions dictate.
The stream API provided by the node-opus
is a higher level API. The Node package should expose the direct packet-per-packet encoding functions as well.
... at least I hope I did that. :|
I'm archiving the repository for lack of interest in maintaining it. Sorry I never got to deal with this issue. Please see @discordjs/opus for an alternative implementation that is based this project but uses more stable Node.js module technology that should break less between Node.js versions.
Does this package allow for changing the bitrate in response to network conditions in a streaming application? It's my understanding that Opus can seamlessly change the encoded bitrate which makes it ideal for a streaming solution where the network conditions may vary. A fullband stream could fall back to narrowband if the connection is poor, for example.
Does Opus handle this natively, or do you need to detect this condition yourself and tell Opus to alter the bitrate accordingly? And can this package do this or is it too simplistic of an implementation right now?
Any info to point me in the right direction would be helpful.