Converting RTMP to WebRTC With Wowza Video
Even though RTMP isn’t commonly used for last-mile delivery anymore, it’s still very popular for first-mile contribution because many encoders still support it. If you want to broadcast to a broad number of viewers with low latency, though, one of your best options is to use WebRTC. Fortunately, Wowza Video makes it possible to use both: you can ingest with RTMP and transcode your stream to WebRTC, allowing you to reap each of their benefits and scale as needed. Watch the tutorial above or read the transcript below to learn how to convert from one protocol to another with the Wowza Video platform.
While WebRTC has a latency of less than 500 milliseconds, being forced to use a desktop browser as an encoder can make things difficult. But with Wowza Video, you can use RTMP for ingest and still output using WebRTC with only a one-to-two second latency.
Start by adding a live stream. Name it something appropriate, and then choose a location closest to where you’re broadcasting from. Next, choose Web Browser WebRTC as the encoder. We’ll also want to prioritize latency, as you won’t be able to adjust that later. Now we can bypass everything else and go straight to finish.
The reason to start with WebRTC as ingest is to create the playback URL immediately. While you may not use it, it’s a great way to first test with. Once the live stream’s created, go to the Playback URL and open it up in a tab. Now we can go to the Video Source and Transcoder tab and edit the information.
We’ll change the encoder to be Other RTMP. At this point, you may also want to change the aspect ratio to the one you plan to use for streaming, and disable authentication, just to make things easier. Don’t forget to save once you’ve finished.
Now back under Overview, we can see the WebRTC playback URL is gone, and the source connection information has changed to use RTMP. Before we make a few more changes, let’s add this information into an encoder such as OBS Studio. Under settings, we can go to Stream, and here we’ll use the “custom” option under Service and then paste in that server information.
While that’s all we need to stream, there are a few settings that you should put in for proper conversion from RTMP to WebRTC. You’ll need the audio to be set at 48 kilohertz and the video at a resolution you plan to stream at. We’ll want the output to use the mode Advanced. Rate control should be CBR with a bitrate of 4,000. The key frame interval needs to be two seconds, CPU set to very fast. The profile for 1080p purposes should be high and will need to tune for zero latency. This should set the B frames and scene cut to zero, but you can also manually add this. Also, under Audio, make sure the bitrate is 128.
Now we should be ready to go back to Wowza Video. There, we’ll make a few more changes before going live. Under Transcoders, select the live stream. In the tab Outputs and Targets, we’ll edit the pass-through output and make a few changes. Video codec needs to be set to H.264. Audio codec needs to be Opus for WebRTC. Everything else can stay the same, as long as they’re in line with the encoder settings.
Once it’s all saved, we can go under Direct Playback URLs. Now, right now, WebRTC output is set to 10 current maximum viewers, but we can change this quite easily to 300 maximum viewers. Okay, now if we go under WebRTC, we can see that we have all the information here under Source to view the RTMP ingest as WebRTC egress. However, we already have this information automatically stored in that WebRTC playback URL, so let’s use it.
Go back to Available Streams, and then select the live stream, and, well, start streaming. Now, this may take a few seconds for it to start up due to all the new configurations, but once it has, go back to OBS Studio and start streaming there as well. Now, from the WebRTC playback URL, we should be able to click, unmute the video, and see our results with a one to two second latency when we compare it with what’s in OBS Studio.
And that’s it for streaming RTMP to WebRTC with only a one-to-two second latency. While you may see even a shorter latency here, it really does depend on your situation. If you’re looking to stream this way to a million viewers, please contact us about our Real-Time Streaming at Scale option here at Wowza.
Search Wowza Resources
About Justin Miller
Justin K. Miller is the video and webinar producer at Wowza Media Systems. He’s responsible for both the live and recorded productions made to educate, train, and inform customers and live video streaming enthusiasts. When not focused on the many facets of video production, Justin spends his free time watching media, modifying 3D printers, designing terrarium topography, breeding poison dart frogs, and raising his two children Jonathan and Alexis.