Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Why OPUS calculates bit rate based on sample rate? (Read 2596 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Why OPUS calculates bit rate based on sample rate?

I'm newbie in this website and I really don't know where exactly should I ask this question ;-;

But since the code is related to OPUS, I think this channel may be a good place to start.

The scenario I'm actually interested in is the following.

Image two users (A and B) are talking with each other in a voip applicaiton. If user A has a very bad internet connection and user B has a really good internet connection I want to change their configuration so they can have a better user experience. User A should have a small sample rate and a small bit rate. And user B should have a high sample rate and bit rate. But a friend of mine told me that you should never alter sample rate. You should leave it to highest value as possible and just alter bit rate. But I really don't know if this is accurate.

Additionally, the code available at https://github.com/pjsip/pjproject/blob/master/pjmedia/include/pjmedia-codec/config.h (PJSIP) explicit says that bit rate value should be left to default value specified by Opus - ZERO(0), which will take into account factors such as media content (speech/music), sample rate, channel count, etc. In other words, in the voip scenario, you should only alter sample rate.

Finally, here is the question. In an application that dynamically changes OPUS configurations for a better user experience should alter only bit rate, only sample rate or both?

Re: Why OPUS calculates bit rate based on sample rate?

Reply #1
Opus has a fixed sample rate of 48 kHz. It can encode from factors of this sample rate as a shortcut to reducing the encoding complexity, which also reduces the bitrate. It will still decode to 48 kHz, regardless.

Applications which alter the experience based on available bandwidth, should try to target the available upstream bandwidth for the audio, with room for anything else the user may be doing. Sample rate can't explicitly target a given bitrate as easily.

Technically, their software should be utilizing a maximum bitrate cap, as an optional feature. At best, it could detect when the stream is falling behind and reduce its send bitrate.

 

Re: Why OPUS calculates bit rate based on sample rate?

Reply #2
In an application that dynamically changes OPUS configurations for a better user experience should alter only bit rate, only sample rate or both?
In most cases, including VoIP, you should only change the bit rate.

The sample rate should be set according to the sample rate of your source audio. If you're switching between different sources with different sample rates, then you can change the sample rate. Otherwise, you should set the sample rate once and never change it.