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
Complete Source Code
Important Implementation Details
RID (Restriction Identifier)
RID (Restriction Identifier)
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)
PLI (Picture Loss Indication)
PLI (Picture Loss Indication)
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
- Network conditions
- Available bandwidth
- Quality switching patterns
Transceiver Direction
Transceiver Direction
The example explicitly sets transceiver directions:This ensures proper negotiation and prevents unnecessary media pipelines.
Quality Selection
Quality Selection
While this example sends all three qualities back, in production you would:
- Monitor bandwidth using RTCP feedback
- Select appropriate quality based on:
- Available bandwidth
- Screen size/viewport
- CPU capabilities
- User preferences
- Switch dynamically between qualities
Browser Configuration
To enable simulcast in the browser, configure the sender:Running the Example
Configure browser for simulcast
Open the simulcast example page which automatically configures three encoding layers
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
Related Examples
- Broadcast - Forward streams to multiple viewers
- Save to Disk - Record specific quality levels
- RTP Forwarder - Forward selected quality via RTP