Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Stereo audio playback in browser

The Opus codec parameters shoul be set on server side to play stereo audio in browser as like as for stream publishing

Code Block
themeRDark
opus_formats = maxaveragebitrate=64000;stereo=1;sprop-stereo=1;

In this case Firefox will play stereo audio without additional setup.

When a stream captured from RTMP, RTSP or VOD source is plaing in browser, audio is usually transcoded to Opus codec. By default, Opus encoder is configured to play a speech and monophonic audio. Encoder bitrate should be raised to 60 kbps or higher to play stereo in browser

...

By default, Chrome browser plays WebRTC stream with stereo sound in Opus codec as mono due to engine bug. Since Web SDK build An additiona client setup is required to workaround this Chrome behaviour depending on client implementation

Using Web SDK

Since Web SDK build 0.5.28.2753.151 this can be worked around using the following playback constraint option is available

Code Block
languagejs
themeRDark
constraints.audio.stereo=true

...

Code Block
languagejs
themeRDark
    session.createStream({
        name: streamName,
        display: remoteVideo,
        constraints: {
            audio: {
                stereo: true
            }
        }
        ...
    }).play();

...

Using Websocket API

If only Websocket API is used in project, it is necessary to disable echo cancellation

Code Block
languagejs
themeRDark
session.createStream({
    name: streamName,
    display: remoteVideo,
    constraints: {
        audio: {
            echoCancellation: false,
            googEchoCancellation: false
        },
        ...
    }
    ...
}).play();

Also the Opus codec parameters should be changed in offer SDP right after its creation

Code Block
languagejs
themeRDark
        var connection = new RTCPeerConnection(connectionConfig, connectionConstraints);
        ...
        connection.createOffer(constraints).then(function (offer) {
          offer.sdp = offer.sdp.replace('minptime=10', 'minptime=10;stereo=1;sprop-stereo=1');
          connection.setLocalDescription(offer).then(function () {
              ...
          });
        });

Additional video stream playing delay

...