tencent cloud

Feedback

Push Configuration

Last updated: 2022-05-06 15:48:05

    To protect your live streaming content, push authentication is enabled for push domains by default. You can use the address generator on the details page of a push domain to generate a push URL, which you can use to push streams (upload live videos) to the CSS platform.

    Notes

    • CSS provides a test domain name xxxx.tlivepush.com. You can use it to test live push, but you’re not advised to use it as the push domain name for business purposes.
    • A push URL is valid before the expiration time you specify. After it expires, you need to generate a new URL.

    Prerequisites

    You have activated the CSS service.

    Authentication Configuration

    1. Go to Domain Management, click the target push domain name or click Manage to enter the domain details page.
    2. Click Push Configuration and, in the Authentication Configuration area, click Edit.
    3. In the pop-up window, toggle on Push Authentication.
    4. Enter the primary key and backup key, and click Save.
      Note:

      The primary key is required and the backup key is optional. Entering both allows you to switch to the other key when one key is disclosed.

    Push Address Generator

    Directions

    1. Go to Domain Management, click the target domain name or click Manage on its right to enter its details page.
    2. Select Push Configuration and, in Push Address Generator, complete the following settings:
      1. Select an expiration time, such as 2021-06-30 19:26:02.
      2. Enter a custom StreamName, such as liveteststream.
      3. Click Generate Push Address to generate an RTMP push URL containing the StreamName.
    3. If you haven’t enabled authentication for your push domain, you can find RTMP and UDP URLs in the Push URL section. Replace StreamName with your stream name and you can use the corresponding playback URLs to play the stream.

    Push URL format

    An RTMP push URL looks like this:

    rtmp://domain/AppName/StreamName?txSecret=Md5(key+StreamName+hex(time))&txTime=hex(time)
    

    It includes the following fields:

    • domain: Push domain name
    • AppName: Live streaming application name, which is live by default and is customizable
    • StreamName: Custom stream name used to identify a live stream
    • txSecret: Authentication string generated after push authentication is enabled
    • txTime: Expiration timestamp set for the push URL in the console
    Note:

    • If you have enabled authentication, the actual expiration time of a URL will be txTime plus the validity period of the key.
    • For the sake of convenience, the time you set in the console is the actual expiration time. If you enable authentication, the system will calculate the txTime when generating push URLs.
    • As long as you start push or playback before the expiration time and the stream is not interrupted, the push or playback can continue even after the URL expires.

    Sample Code of Push URL

    We offer sample code in PHP and Java for generating push URLs. To view the code, follow the steps below:

    1. Log in to the CSS console and click Domain Management.
    2. Click a push domain name or click Manage on the right to enter its details page.
    3. Select Push Configuration and scroll down to find Push Address Sample Code.
    4. Click the tab to view the sample code for PHP or Java.
      /**
      * Get the push URL
      * If you do not pass in the authentication key and URL expiration time, a URL without hotlink protection will be returned.
      * @param domain: Your push domain name
      *        streamName: A unique stream name to identify the push URL
      *        key: Authentication key
      *        time: Expiration time (accurate to the second). Example: 2016-11-12 12:00:00
      * @return String url
      function getPushUrl($domain, $streamName, $key = null, $time = null){
      if($key && $time){
        $txTime = strtoupper(base_convert(strtotime($time),10,16));
        //txSecret = MD5( KEY + streamName + txTime )
        $txSecret = md5($key.$streamName.$txTime);
        $ext_str = "?".http_build_query(array(
                  "txSecret"=> $txSecret,
                  "txTime"=> $txTime
        ));
      }
      return "rtmp://".$domain."/live/".$streamName . (isset($ext_str) ? $ext_str : "");
      }
      echo getPushUrl("123.test.com","123456","69e0daf7234b01f257a7adb9f807ae9f","2016-09-11 20:08:07");
      

    Subsequent Operations

    You can start pushing streams after the push URL is generated. For details, see Live Push.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support