Working with VP8 Simulcast

What’s Simulcast?

An SFU (Selective Forwarding Unit) is a media infrastructure component used for scaling videoconferences. Twilio’s Group Rooms is based on an SFU that enables developers to add a large number of Participants to a video room by forwarding audio, video, and data information from each publisher to any of its subscribers. Given that this forwarding takes place at Twilio’s Cloud, there’s no additional client-side CPU or memory consumption as the number of Room Participants increases. However, the problem in these architectures is that SFUs just forward and can neither transcode nor modify the video. Hence, when there are subscribers with limited receive bandwidth, publishers need to reduce quality to adapt to the worst of them so that no subscriber is congested. As shown in the following figure, this is suboptimal as we are constraining the quality of participants that could communicate with much higher quality.

In Group Rooms, by default the video quality is constrained to the worst of the available bandwidths of the participants.

Simulcast is a technique designed for solving this problem. Simulcast involves the simultaneous sending of different versions of the same video track encoded independently at different resolutions and framerates. With Simulcast, the SFU has several versions of the track with different qualities, so that it can forward higher qualities to higher bandwidth subscribers and lower qualities to lower bandwidth ones. In more technical jargon, we say that Simulcast is a mechanism for providing scalability to non-scalable video codecs such as VP8.

Simulcast involves the simultaneous sending of several version of the same video track so that the SFU infrastructure can forward different qualities to different subscribers depending on their network status and capabilities.

Enabling Simulcast in your Twilio application

Simulcast can be enabled in Group Room clients sending media to Twilio’s SFU. The following table illustrates Twilio’s current support for Simulcast:

Twilio Video SDK Browser (or N/A) VP8 Simulcast Support (only Group Rooms)
JavaScript Chrome Yes (SDK v1.7.0+)
JavaScript Firefox No
JavaScript Safari No
Android N/A No
iOS N/A No

Enabling Simulcast in Chrome using JavaScript SDK (required v1.7.0+)

By default, Simulcast is disabled. You can enable Simulcast in a per-Participant basis at Room connect-time. This is done using the ConnectOptions as shown in the following code snippet:

// Web Javascript
const room = await connect(token, {
    preferredVideoCodecs: [
      { codec: 'VP8', simulcast: true }
    ]
});

Any Group Room Participant with VP8 Simulcast enabled publishes all its video tracks using VP8 Simulcast. Once this is done, Twilio’s video infrastructure leverages Simulcast tracks to provide the best possible quality to any subscriber without requiring any additional action from you.

Pros and cons of Simulcast

When enabling Simulcast in your Group Rooms application you enjoy the following advantages:

  • VP8 subscribers enjoy differentiated quality adapted to their available bandwidth. This significantly improves the quality on Group Rooms with many heterogeneous Participants.
  • VP8 subscribers are isolated from each other so that a subscriber with a degraded network link does not affect the reception quality of other subscribers.

On the other hand, Simulcast also has some drawbacks:

  • Simulcast only contributes to improve the video quality in Group Rooms with 3 or more Participants.
  • Publishers battery consumption is higher due to the need of encoding multiple versions of the same video track.
  • Publishers bandwidth consumption is higher (up to double in some cases) due to sending multiple versions of the same video track. Note that this increase does not impact your Programmable Video costs as Twilio does not charge upstream (i.e. from sender to Twilio’s cloud) bandwidth.

Limitations and known issues

  • Simulcast should only be used in Group Rooms. Using it in P2P Rooms does not improve quality and only contributes to degrade application performance.
  • Simulcast is only supported for the VP8 video codec.
  • The combination of Simulcast and oscillating bandwidth conditions at the publisher might generate suboptimal recording qualities. If the primary objective of your application is to have optimal recording video quality you might prefer not to enable Simulcast on it.
Luis Lopez

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.