Try Live Demo

Developers can make their app users broadcast live video not only from their browser with WebRTC but also from OBS, thanks to WebRTC Adapter. Let’s start by introducing Open Broadcaster Software (OBS).

OBS (Open Broadcaster Software) is a free open-source software for video recording and live streaming. You can use either your PC’s embedded camera or an externally connected one as a video source with OBS. Sound sources can also be configured with it. Ant Media Server Enterprise is fully compatible with OBS.

A step-by-step guide on how to use OBS for WebRTC streaming

1. Install the OBS

Download Open Broadcaster Software from obsproject.com and install it.

2. Provide sources

By default, OBS starts to capture from your built-in camera if it exists. You can add or remove video/audio sources from the Sources section.

3. Configure OBS

We assume that your Ant Media Server accepts all streams (e.g, there is no security option enabled).

  • Click Settings in the Window and then select Stream it on the left side menu.
  • Choose Custom Streaming Server in the Stream Type dropdown menu.
  • In the URL box, type your RTMP URL without the stream id. It’s like rtmp://your_server_domain_name/LiveApp
  • In the Stream key, you can write any stream id because we assume that no security option is enabled.

    obs

When you use tokens, you need to generate a publish token and use it in this format inside the stream key: streamid?token=tokenid

obs rtmp token

Tune for ultra-low latency streaming

OBS is not optimized for ultra-low latency streaming by default. If you use it to push an RTMP stream and play it with WebRTC, please go to Settings > Output and make the rate control CBR (Constant Bitrate) and tune for zerolatency. You can also adjust the bitrate to meet your quality and internet bandwidth requirements.

Furthermore, the keyframe interval should be set to 1. Please see the screenshot below for reference:

obs tuned

Please keep in mind that if your network is not stable enough to send the requested bitrate all the time, you may see freezes in playing the stream.

4: Start streaming

Close Settings window and just click the “Start Streaming” button in the main window of OBS.

obs streaming

Congrats! You’re publishing a live RTMP stream.

Troubleshooting

If you have had problems with stream quality, you should check the following indicators in OBS.

Stream health

Stream health parameters are located at the bottom right. There are 3 stream health parameters: Dropped Frames, CPU and Stream health color.

  • Dropped frames: This value should be 0. If it increases, you may decrease your FPS or bitrate parameters in the OBS settings.
  • CPU: CPU value is important for streaming quality. We recommend that it never exceed 70%.
  • Stream health color: This color should be green. If it has a color between yellow and red, you may have problems with your stream quality.

obs troubleshooting

Encoding overloaded warning

If your PC cannot handle the stream with the parameters you set, this warning appears. In this case, you may want to decrease the resolution and bitrate or change the encoder preset value to one with high speed and low quality.

obs encoding

Streaming recorded VoD files

If you want to stream your VoD files, please consider your VoD encoder settings as below:

  • Profile: Baseline
  • Tune: Zerolatency

You can change your VoD encoder settings as below:

ffmpeg -i input.mp4 -profile baseline -tune zerolatency output.mp4

We hope this tutorial will be helpful for you. Please feel free to contact us if you have any questions; just send an email to contact@antmedia.io

Categories: Tutorial

Mohit Dubey

Mohit is your go-to Technical Support Engineer at Ant Media Server with the aim to make the streaming seamless and accessible, proficient in navigating cloud platforms. He likes to contribute towards product installation/deployment, testing, documentation, troubleshooting, and customer support, etc. Also, well-versed with AWS Streaming Wizard and the ins and outs of Ant Media Server.