Skip to main content
The simulcast example demonstrates how to receive a single WebRTC track containing multiple simulcast streams (different quality levels) and demux them into separate tracks. This is essential for implementing adaptive bitrate streaming, bandwidth-adaptive video conferencing, and multi-quality broadcasting.

Overview

Simulcast allows a sender to transmit the same video at multiple quality levels (resolutions/bitrates) within a single track. The receiver can then select which quality to display based on available bandwidth, screen size, or user preference. This example receives all three simulcast layers and sends them back as independent tracks.

Key Features

  • Receives single track with 3 simulcast streams (low, medium, high quality)
  • Demultiplexes streams by RID (Restriction Identifier)
  • Returns each quality as a separate independent track
  • Periodic PLI (Picture Loss Indication) for keyframe requests
  • Real-time quality switching capability

Simulcast Stream Naming

The example uses standard simulcast naming:
  • “q” (quarter): Low quality/resolution stream
  • “h” (half): Medium quality/resolution stream
  • “f” (full): High quality/resolution stream

How It Works

1

Create Output Tracks

Prepare three local tracks for the demuxed streams:
2

Add Transceivers

Configure transceivers for receiving and sending:
3

Setup RTCP Processing

Read RTCP packets for all senders:
4

Handle Incoming Track

Demux based on RID and forward to appropriate output track:

Complete Source Code

Important Implementation Details

RID identifies which simulcast stream a packet belongs to:
Common RID values:
  • “q” or “0”: Lowest quality (quarter resolution)
  • “h” or “1”: Medium quality (half resolution)
  • “f” or “2”: Highest quality (full resolution)
The RID maps incoming packets to the correct output track for demuxing.
The example sends PLI every 3 seconds to request keyframes:
Why this matters:
  • Ensures each stream has recent keyframes
  • Enables quick quality switching
  • Helps with error recovery
For production, adjust PLI frequency based on:
  • Network conditions
  • Available bandwidth
  • Quality switching patterns
The example explicitly sets transceiver directions:
This ensures proper negotiation and prevents unnecessary media pipelines.
While this example sends all three qualities back, in production you would:
  1. Monitor bandwidth using RTCP feedback
  2. Select appropriate quality based on:
    • Available bandwidth
    • Screen size/viewport
    • CPU capabilities
    • User preferences
  3. Switch dynamically between qualities
Example quality selection logic:

Browser Configuration

To enable simulcast in the browser, configure the sender:

Running the Example

1

Start the application

2

Configure browser for simulcast

Open the simulcast example page which automatically configures three encoding layers
3

Complete handshake

Exchange SDP offer/answer through the copy-paste signaling
4

Observe streams

You should see:
  • Terminal logs showing PLI requests for each RID
  • Three separate video elements in the browser showing different qualities
  • All three streams playing simultaneously

Use Cases

Adaptive Streaming

Automatically switch quality based on network conditions for smooth playback

Video Conferencing

Show active speaker in high quality, thumbnails in low quality

Broadcasting

Serve different qualities to viewers with varying bandwidth

Recording

Record multiple qualities simultaneously for later transcoding

Performance Considerations

Bandwidth Usage: Simulcast increases upload bandwidth by 2-3x compared to single stream. Ensure the sender has sufficient bandwidth:
  • Single stream: ~1-2 Mbps
  • Simulcast (3 layers): ~2.5-3.5 Mbps
The benefit is that each receiver can choose their quality, reducing download bandwidth.
For optimal results:
  • Use simulcast when you have multiple viewers with varying bandwidth
  • Consider SVC (Scalable Video Coding) as an alternative with lower upload requirements
  • Implement adaptive bitrate switching on the receiver side
  • Monitor RTCP feedback for quality decisions