How-to Broadcast a WebRTC stream to Twitch
Tags: webrtc, twitch, webdev, tutorial
Published: 2023-08-01 16:03:31

Recently, while exploring [syndicating Dolby.io WebRTC](https://docs.dolby.io/streaming-apis/docs/webrtc-whip) streams, I learned that [Twitch has added support for WebRTC Ingest](https://www.linkedin.com/posts/sean-dubois_twitch-activity-7053056800861933568-TTPW/) or [WHIP](https://datatracker.ietf.org/doc/draft-ietf-wish-whip/) as it is known in the industry.

WebRTC for streaming is an exciting choice because it can decrease stream latency compared to traditional protocols such as RTMP and HLS. When ingested, Twitch will transmux the WebRTC stream into something the platform supports (HLS), so that adds latency, slowing down the feed.

With that said, WHIP support is a great step for the community and with OBS now adding support for WebRTC, I thought I'd have to try it out.

In this guide, we'll showcase how to stream WebRTC from OBS into Twitch.

## Setting up OBS for WebRTC
The core OBS project is working to add WebRTC, however, at the moment it is still an experimental build. You can try out this build by downloading the version relevant to your system [here](https://github.com/obsproject/obs-studio/actions/runs/5227109208).

Once downloaded, extract the project and install it. 

## Streaming WebRTC from OBS to Twitch
With the project installed and launched, navigate to: 
`Settings -> Stream`

Inside of `Stream` select `WHIP` as your service:

![The WHIP settings in OBS for WebRTC streaming](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zziaxvtcx6wnwbpw75am.png)

To start a WebRTC stream to Twitch you need the `Server` path and your `Stream key`.

### The Twitch WHIP server
The server is (_currently_) the same for everyone:
`https://g.webrtc.live-video.net:4443/v2/offer`

_**Note:** This server currently only supports H264 and Opus encoded streams._

### Getting Your Twitch Stream Key
Your Twitch Stream Key can be found on your [dashboard](https://dashboard.twitch.tv/) once you've logged in, under:
`settings -> stream`

![Your Twitch API Stream Key on the Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22v9s5k3vdu0djamhb7p.png)

Copy both the `Server` URL and the `Stream Key` into the `Server` and `Bearer Token` inputs within OBS.


![Twitch credentials added to OBS for WHIP streaming](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/37isoynu2aofbef98eht.png)

Click `Apply`, set up OBS as usual, and click `Start Stream` to begin your WebRTC broadcast to Twitch.


![Braden Riggs broadcasting a WebRTC stream from OBS to Twitch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugj1ya07nxf2dgi8qg5h.png)

### Learn More

Broadcasting a WebRTC stream to Twitch is an great feature for the site as it allows people to easily [syndicate their WebRTC streams](https://docs.dolby.io/streaming-apis/docs/syndication) to a popular platform. Because Twitch transmuxes the WebRTC stream, some delay is added, so if you're looking for an end-to-end white-label real-time streaming solution, check out [Dolby.io Real-time Streaming](https://dolby.io/products/real-time-streaming/).

A special shout out to [Sean DuBois](https://www.linkedin.com/in/sean-dubois/) for his work on both the OBS project and on Twitch's WHIP support.