Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opus codec ignores bitrate settings #41

Closed
jitsi-jenkins opened this issue Apr 6, 2015 · 11 comments
Closed

Opus codec ignores bitrate settings #41

jitsi-jenkins opened this issue Apr 6, 2015 · 11 comments
Labels

Comments

@jitsi-jenkins
Copy link

http://lists.jitsi.org/pipermail/users/2014-June/007435.html

I've tried to stream audio to a SIP Account with the opus codec. Setting: 128 Kpbs.
I've started the connection and it works, but the upstream was only at 40 Kbps and not at 128 Kbps like configured.

(Issue migrated from https://trac.jitsi.org/ticket/1293)
image

@jitsi-jenkins
Copy link
Author

I can confirm this issue is present with all of Linux, Windows, and Android versions of jitsi. If someone can point me to the involved parts of the code I may be able to at least have a look at what is going wrong here.

@jitsi-jenkins
Copy link
Author

@Flohack74
Copy link

Did someone already enable debug log and check if the used value is correct in the following output?

 logger.debug(
"Encoder settings: audio bandwidth " + bw + ", bitrate "
+ Opus.encoder_get_bitrate(encoder) + ", DTX "
+ Opus.encoder_get_dtx(encoder) + ", FEC "
+ Opus.encoder_get_inband_fec(encoder));

@bgrozev
Copy link
Member

bgrozev commented Dec 7, 2015

Yes, I checked that and it was correct.

@Flohack74
Copy link

Ok so its strange because you can see the log information tries to ask Opus itself to report the bitrate. Jitsi cannot do more than to ask for the bitrate in setup and then check if it has been set. If the codec itself ignores the request somehow we cannot know at the moment Im afraid. It would need some more testing of the used Opus lib and whats going wrong there.

@Flohack74
Copy link

Boris, I also wrote you a mail...
I think I found the Opus issue... look in the JNIEncoder.java into this function setFormatParameters... there maxaveragebitrate is used to set the bitrate, if any supplied userbitrate is higher:

 /**
     * Sets the format parameters.
     *
     * @param fmtps the format parameters to set
     */
    @Override
    public void setFormatParameters(Map<String, String> fmtps)
    {
        if (logger.isDebugEnabled())
            logger.debug("Setting format parameters: " + fmtps);

        /*
         * TODO Use the default value for maxaveragebitrate as defined at
         * http://tools.ietf.org/html/draft-spittka-payload-rtp-opus-02#section-6.1
         */
        int maxaveragebitrate = 40000;

        try
        {
            String s = fmtps.get("maxaveragebitrate");

            if ((s != null) && (s.length() != 0))
                maxaveragebitrate = Integer.parseInt(s);
        }
        catch (Exception e)
        {
            // Ignore and fall back to the default value.
        }
        Opus.encoder_set_bitrate(
                encoder,
                (maxaveragebitrate < bitrate) ? maxaveragebitrate : bitrate);

Can it be that this function runs after the initial setup, thereby limiting the encoder to 40kbps as the user wrote? Im sorry I icant test this, I have no Java environment here

@bgrozev
Copy link
Member

bgrozev commented Jan 28, 2016

Absolutely, this looks like its the problem! Thank you for posting it (I have not received an email from you).

I just pushed a fix. Unfortunately because of this issue I haven't tested it with Jitsi, and I don't know when it will land there.

@Flohack74
Copy link

You are welcome. By the way I dont get the point of having maxaveragebitrate and bitrate in this code. Why is this necessary? (maxaveragebitrate < bitrate) ? maxaveragebitrate : bitrate);

@bgrozev
Copy link
Member

bgrozev commented Jan 29, 2016

maxaveragebitrate comes from the remote side. We honor it by not exceeding it, but we shouldn't increase our sending bitrate just because the remote side reported that they can handle it. In practice, if the remote side is Jitsi, maxaveragebitrate isn't included.

@Flohack74
Copy link

Can I already test this in nightly?

@ibauersachs
Copy link
Member

Not in the Jitsi nightlies. As Boris said, this will take quite some time.

@bgrozev bgrozev closed this as completed Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants