How to Use

Last update:2025-02-18 09:54:42

This document will walk you through the configurations needed to utilize WebRTC for both pushing and pulling streams, ensuring low-latency and efficient delivery.

Streaming Workflows

Typically, our users utilize two main streaming workflows:

  • RTMP Push, WebRTC Pull: This common setup involves using RTMP (Real-Time Messaging Protocol) to push your stream to our servers, and then using WebRTC to pull and play the stream on various clients.
  • WebRTC Push, WebRTC Pull: For even lower latency scenarios, you can also push streams directly using WebRTC.

This guide covers both scenarios to help you get started.

Part 1: RTMP Push Stream to WebRTC Pull Stream

This is the most common workflow. You will push your stream to our servers using RTMP, and viewers will pull the stream using WebRTC for low-latency playback.

1.1 Setting up RTMP Push with OBS Studio

OBS Studio (Open Broadcaster Software) is a popular free and open-source software for video recording and live streaming. Here’s how to set it up for RTMP push for WebRTC compatibility:

Important Note: B-frame Removal

WebRTC video encoding standards do not natively support B-frames (Bi-directional predicted frames). If your RTMP push stream includes B-frames, playback via WebRTC may experience stuttering. Therefore, it’s crucial to configure OBS Studio to remove B-frames during the encoding process.

Configuration Steps in OBS Studio:

  1. Open OBS Studio Settings: Click on “Settings” in the main OBS Studio window.

  2. Navigate to Output Settings: Go to the “Output” tab in the Settings window. Ensure the “Output Mode” is set to “Advanced”.

  3. Configure Video Encoding (x264): In the “Streaming” tab under “Output”, ensure you are using the x264 encoder for video. Within the x264 encoder settings, find the “x264 Options (separated by space)” field and add the parameter: bframes=0. This explicitly disables B-frames in your video stream.

  4. Start Streaming: Once configured, you can start your RTMP stream from OBS Studio as usual.

1.2 WebRTC Pull Stream Playback

CDNetworks supports WebRTC pull streams on various client platforms:

1.2.1 Web Browsers

Important Note: Standard WebRTC Support in Browsers

Web browsers generally support standard WebRTC codecs. This means:

  • Video Codec: H.264 (without B-frames) is supported. As mentioned earlier, ensure your push stream is configured to remove B-frames.
  • Audio Codec: Opus is the preferred audio codec. AAC audio in your push stream will require transcoding, which may introduce latency.

If your source stream uses video or audio formats that are not standard for WebRTC in browsers, CDNetworks can transcode your stream to ensure compatibility. Please contact our customer support to enable transcoding. Please be aware that transcoding can add latency to the stream and may incur additional costs. Contact customer service to discuss optimal encoding settings for your workflow.

1.2.2 iOS and Android Apps

  • Dedicated SDKs: For native iOS and Android applications, we provide dedicated SDKs that offer enhanced features and broader codec support, including:
    • B-frame support
    • H.265 (HEVC) video codec
    • AAC audio codec
  • SDK Testing and Integration: To test our iOS and Android SDKs and for assistance with integration into your mobile applications, please contact our customer service team.

Part 2: WebRTC Push Stream to WebRTC Pull Stream

For ultra-low latency streaming, CDNetworks also supports WebRTC push streams. This eliminates the need for RTMP and potential transcoding, further minimizing latency.

Key Considerations for WebRTC Push Streams:

  • Codec Limitations: WebRTC push streams, for optimal compatibility and lowest latency, should adhere to the standard WebRTC codec requirements:

    • Video Codec: H.264 (without B-frames)
    • Audio Codec: Opus

    Pushing streams using other codecs (e.g., AAC audio, H.264 with B-frames via RTMP) will necessitate transcoding on our platform when pulling via WebRTC, which will increase latency and potentially costs.

2.1 Setting up WebRTC Push with OBS Studio (using Plugin)

To push WebRTC streams from OBS Studio, you will need to install a specific plugin provided by CDNetworks. Currently, this plugin is only supported for Windows versions of OBS Studio.

Prerequisites:

  1. OBS Studio Version: Ensure you are using OBS Studio version 26 or higher. You can download the latest version from the official OBS Project website: https://obsproject.com/download
  2. Download CDNetworks WebRTC Plugin: Download the necessary plugin from: obs-webrtc-plugin This plugin is essential for enabling WebRTC push functionality in OBS Studio.

Installation Steps:

  1. Extract Plugin Files: Unzip the downloaded obs-webrtc-plugin.zip file to a location on your computer.

  2. Copy services.json: Navigate to the extracted folder and find the file services.json located in: obs-webrtc-plugin\data\obs-plugins\rtmp-services. Copy this services.json file.

  3. Replace services.json in OBS Installation Directory: Locate your OBS Studio installation directory. This is typically found in C:\Program Files\obs-studio\data\obs-plugins\rtmp-services or a similar location depending on your installation choices. Replace the existing services.json file in the OBS installation directory with the one you copied from the plugin.

  4. Copy obs-webrtc.dll: From the extracted plugin folder, navigate to obs-webrtc-plugin\obs-plugins\64bit. Copy the file obs-webrtc.dll.

  5. Paste obs-webrtc.dll to OBS Plugins Directory: Paste the copied obs-webrtc.dll file into the obs-plugins\64bit directory within your OBS Studio installation directory.

  6. Verify services.json in Plugin Config Directory (If Necessary): In some cases, OBS Studio might also load service configurations from a user-specific directory. If you encounter issues pushing the stream after the above steps, check and update the services.json file in this directory as well: C:\Users\[Your User Name]\AppData\Roaming\obs-studio\plugin_config\rtmp-services. Replace the services.json file here with the one from the plugin zip if needed.

Post-Installation Steps:

Once you have successfully installed the WebRTC plugin, follow these steps to configure OBS Studio for WebRTC push streaming

  1. Obtain Push and Pull URLs: Structure your own WebRTC URLs for initial setup. Here’s an example of how your WebRTC Push and Pull URLs might look:

    • WebRTC Push URL:

      [http://your-push-server.com/live/your_stream_name.sdp](http://your-push-server.com/live/your_stream_name.sdp)
      
    • WebRTC Pull URL:

      [http://your-pull-server.com/live/your_stream_name.sdp](http://your-pull-server.com/live/your_stream_name.sdp)
      

    Note:
    Replace http://your-push-server.com and http://your-pull-server.com with your actual server address, and your_stream_name with your desired stream identifier. The .sdp extension is typical for WebRTC session descriptions.

2.2 Configure OBS Stream Settings

  1. Configure OBS Stream Settings:

    • Open OBS Studio Settings and go to the “Stream” tab.
    • In the “Service” dropdown, you should now find a new option labeled “Wangsu webRTC” (or similar, depending on the plugin). Select this option.
    • In the “Server” field, leave it as “default”.
    • In the “Stream Key” field, enter your WebRTC push URL.

  2. Start Streaming: With these settings configured, you should now be able to start your WebRTC push stream from OBS Studio.

Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!