Streaming

Controlling the Publisher Bitrate in Millicast

Controlling the Publisher Bitrate in Millicast
SUMMARY

By default, there are no bitrate limitations imposed on a WebRTC stream, and the publishing client will attempt to push the highest quality stream possible based on the capabilities of the hardware and available bandwidth


By default, there are no bitrate limitations imposed on a WebRTC stream, and the publishing client will attempt to push the highest quality stream possible based on the capabilities of the hardware and available bandwidth. This is not ideal in a one-to-many broadcast scenario where each viewer’s available bandwidth will vary widely. Simulcast for WebRTC will solve this problem, but in the meantime we recommend that you manually set the publishing bitrate to a moderate limit and this article will help you do this.

Putting a limit on the bitrate is done on the publishing client. A bitrate limit can be set for each of the available media descriptions. Media descriptions are part of the SDP, and you can learn more about SDP from the following links:

https://en.wikipedia.org/wiki/Session_Description_Protocol https://developer.mozilla.org/en-US/docs/Glossary/SDP

Here is a typical SDP message:

v=0 o=alice 2890844526 2890844526 IN IP4 host.anywhere.coms= c=IN IP4 host.anywhere.com
t=0 0
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125

Here is a SDP message when a bitrate limit of 500 kbps has been applied to the video media description:

v=0 o=alice 2890844526 2890844526 IN IP4 host.anywhere.com
s= c=IN IP4 host.anywhere.com
t=0 0

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114
b=AS:500

Notice the b=<modifier>:<bandwidth-value> line used to define the value for the bitrate maximum.

Shoutout to Sergio from the CoSMo team on developing WebRTC Semantic SDP (https://www.npmjs.com/package/semantic-sdp). WebRTC Semantic SDP is an excellent tool for parsing a SDP; say if you wanted to add a bitrate limit on a video media description.

Here’s a JS example showing how straightforward it is to set a bitrate limit to the video media description using WebRTC Semantic SDP:

applyBandwidthRestriction(sdp, bitrate) {
let offer = SemanticSDP.SDPInfo.process(sdp);
let videoOffer = offer.getMedia(“video”);
videoOffer.setBitrate(bitrate);
return offer.toString();
}

We hope you find this useful! Please feel free to comment with any feedback or suggestions.

Leave a Comment

Ryan Jespersen

Director of Product Strategy

Ryan Jespersen has extensive experience in the digital video, broadcast and streaming industries, specializing in live streaming workflows, protocols, transcoding, cloud computing, and complex video delivery systems at companies including Wowza, Millicast and now Dolby.

Get Started

Drive real-time interactions and engagement with sub-second latency

We are more than just a streaming solutions provider; we are a technology partner helping you build a streaming ecosystem that meets your goals. Get started for free and as you grow, we offer aggressive volume discounts protecting your margins.

Developer Resources

Explore learning paths and helpful resources as you begin development with Dolby.io.

Copy link
Powered by Social Snap