Documentation
Server_APIs_v2 Server APIs v2
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Server APIs v2
  • Streaming control
  • RTMP stream publishing and pulling scheduling

RTMP stream publishing and pulling scheduling

Last updated:2024-07-09 20:00

1 Description

Calling this interface can initiate RTMP streaming scheduling, supporting both "pull" and "publish" scheduling modes.

When you need to manually publish or pull RTMP streaming from ZEGOCLOUD's audio and video cloud, you can use this interface to obtain the RTMP streaming publish or pull nodes. After developers pass the stream ID (StreamId), scheduling mode (Type), client IP (ClientIP), and sequence number (Sequence) to the server, ZEGOCLOUD media server (RTC service) returns the scheduling result set for clients to publish or pull streams.

For example, when using third-party streaming tools like OBS to publish RTMP streams, scheduling for streaming is required. Similarly, when using a third-party player to pull and play RTMP streams, scheduling for pulling streams is necessary.

When using this interface for the first time, you need to contact ZEGOCLOUD technical support for configuration.

2 Interface prototype

  • Request method:GET
  • Request address:https://rtc-api.zego.im/?Action=RTMPDispatchV2
  • Transfer protocol:HTTPS
  • Call frequency limit (under the same AppID): 40 times per second

3 Request parameters

Listed below are the parameters specific to this request and part of the public request parameters. For the complete list of public request parameters, see Server APIs public request parameters.

In the testing environment (For details, see the description of the isTest parameter in Accessing server APIs - Public request parameters), the stream IDs need to be prefixed with zegotest-AppId-. For example, if the unique part of the stream ID is test and the AppID is 123456789, then the full stream ID should be zegotest-123456789-test.

Parameter Type Is it required Description
StreamId
String
Yes
Stream ID,a string of up to 256 characters in length.

  • The stream ID is defined by you.
  • When streaming publishing, it is necessary to ensure that the stream name is globally unique within the entire AppID. If different users within the same AppID publish streams with the same stream name, it will result in the failure of the user who publishes the stream later.
  • Only supports numbers, English characters and '-', '_'.
Sequence
Int64
Yes
Request sequence number; only used for account reconciliation requests. It is recommended to use a timestamp (in milliseconds) for this purpose.
Type
String
Yes
Scheduling mode. 

  • pull:Get the RTMP pulling node.
  • push:Get the RTMP publishing node.
    ClientIP
    String
    No
    Optional: If available, please provide the client IP address, for example, 119.23.242.129.

    Currently, IPv6 format IP addresses are not supported.

    4 Request example

    https://rtc-api.zego.im/?Action=RTMPDispatchV2
    &StreamId=rtc01
    &Sequence=1617249600001
    &Type=pull
    &ClientIP=47.102.152.118
    &<Public request parameters>

    5 Response parameters

    Parameters Type Description
    Code
    Number
    Return code.
    Message
    String
    Operation result description.
    RequestId
    String
    Request ID.
    Data
    Object
    Response data.

    6 Response example

    {
        "Code":0,
        "Message":"ok",
        "RequestId":"5094436160208407316",
        "Data":[
            "rtmp://81.69.49.115:1935/1540531164/caodantest"
        ]
    }

    7 Return code

    Listed below are the return codes related to this API. For the complete list of return codes, see Return codes.

    Return code Explanation Handling Suggestions
    1010、30002 The frequency of interface calls is too high. Please reduce the frequency of API requests.
    1001 Dispatch failed. Please contact ZEGOCLOUD technical support for assistance.
    1002 Publishing node is empty. Please contact ZEGOCLOUD technical support for assistance.
    1003 Pulling node is empty. Please contact ZEGOCLOUD technical support for assistance.
    1005 App is not online. Please contact ZEGOCLOUD technical support for assistance.
    1006 Invalid parameter. Please contact ZEGOCLOUD technical support for assistance.
    30003 Internal error. Please contact ZEGOCLOUD technical support for assistance.
    30004 Error in parameter isTest. Please check if the common request parameter isTest is correct.
    30005 Invalid AppId. Please check if the AppId is correct.
    30009 Invalid StreamId,the stream name is not standardized. Please check if the StreamId meets the naming encoding specifications.
    30010 Invalid dispatch action. Please check if the Type is correct.
    30011 Invalid client IP address. Please check if the ClientIP is correct.

    Instructions for using the old interface

    Use RTMPDispatch to access the ZEGOCLOUD server

    The difference between RTMPDispatchV2 (recommended) and RTMPDispatch is that when accessing the ZEGOCLOUD server:

    • The RTMPDispatchV2 is being used, and the data returned by the ZEGOCLOUD server is in the form of a URL.
    • The RTMPDispatch is being used, and the data returned by the ZEGOCLOUD server is in the form of IP Port.

    Request address:https://rtc-api.zego.im/?Action=RTMPDispatch

    Response example:

    {
        "Code":0,
        "Message":"ok",
        "RequestId":"5094436160208407316",
        "Data":[
            "81.69.49.115:1935"
        ]
    }
    Page Directory
    • Free trial
    • 提交工单
      咨询集成、功能及报价等问题
      电话咨询
      400 1006 604
      Get Consulting
      Scan Wechat QR code