logo
Live Streaming
On this page

OBS Streaming with WHIP Protocol


WHIP Protocol Introduction

WHIP (WebRTC-HTTP Ingestion Protocol) is a standard protocol based on HTTP that allows you to use HTML5 and different clients to push/pull WebRTC live streams to/from streaming servers or CDNs.

Using WHIP can significantly improve the live streaming experience:

  • Weak network resistance: WebRTC streaming takes advantage of the UDP protocol, providing stronger weak network resistance.
  • Low latency: Reduces latency by about 150 ms compared to RTMP.
Notes

OBS V30.0 and later versions (after October 2023) support the WHIP protocol. Older versions of OBS need to integrate plugins to implement WebRTC streaming.

Prerequisites

  • You have contacted ZEGOCLOUD Technical Support to open the relevant permissions for tool streaming to the ZEGO server, and have applied for and configured the WHIP domain.
  • Prepare a third-party streaming tool, such as OBS.

Usage Steps

Generate streaming URL

After applying for the WHIP domain, the streaming URL is spliced according to the following format.

https://i-whip{appid}.whip.zegotech.cn/whip/v1/{appid}/{streamId}?userId={userId}&zgVer=v1&zgExpired={expire}&zgNonce={nonce}

Parameter Description

Parameter NameDescription
appidUser's appid, consistent with the domain application.
streamIdThe ID of the audio and video stream, customized by the user.
userIdThe ID of the streaming user.
expireThe expiration time of the Token, refer to the Token Generation section.
nonceRandom string, refer to the Token Generation section.

Generate TOKEN

The following is a list of calculation parameters for the authentication Token. Parameter names are case-sensitive.

Parameter NameValue TypeRequiredDescription
appidstringYesThe appid assigned by ZEGO to the customer, only used to participate in Token calculation.
streamIdstringYesStream name, only used to participate in Token calculation.
zgExpiredint64YesToken expiration time. The value is a Unix second-level timestamp, i.e., the number of seconds from 1970-01-01 00:00:00 UTC to now, participating in Token calculation and composing authentication parameters.
Warning
It is recommended that users set a reasonable expiration time. If an expired Token is used, streaming will fail.
zgNoncestringYesNumber once, to avoid Token replay, reserved for implementation. It is recommended that the length does not exceed 15 bytes and can take the current millisecond number, participating in Token calculation and composing authentication parameters.
zgPrivilegestringYesIndicates authentication permissions:
  • 0: Indicates playing stream permission only
  • 1: Indicates publishing and playing stream permission
Only used to participate in Token calculation.
Notes
The media server will decide this parameter based on whether the request is for publishing or playing stream; when the customer backend calculates the Token, decide this parameter value based on whether this user is used for publishing or playing stream, and then participate in Token calculation.
keystringYesAuthentication key.
Warning
ServerSecret needs to specify the corresponding key based on whether it is publishing stream authentication or playing stream authentication.
  1. Sort and concatenate all parameters that need to participate in Token calculation except key in ascending order, and then concatenate key at the end.
let str = "appid=176xxxx14&streamId=stream_1xxxxx4&zgExpired=86400&zgNonce=1760511934298&zgPrivilege=1&key=e0xxxxxxxxxxd";
  1. Perform sha256 encryption on str, and the resulting string is the Token.
b0f8c8e4c6f5b3a8xxxxxxxxxxxxxxxxxxxxx0d9e8f7a6b5c4d3e2f1a0b9

OBS Streaming

1

Open OBS, set up capture sources, and enter settings options.

2

Click Live to enter the streaming URL settings interface.

  1. Select service type as: WHIP.
  2. Fill in the live streaming URL in Server.
  3. Fill in Token in Bearer Token.
3

Start live streaming.

FAQ

ZEGO provides publish_start (start streaming) and publish_stop (stop streaming) callback notifications. If needed, please contact ZEGOCLOUD Technical Support for configuration.

Previous

RTMP Push Stream to ZEGO Server

Next

Use Local Broadcast

On this page

Back to top