tencent cloud

Feedback

Push Configuration

Last updated: 2022-07-07 17:04:32

    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 push streams for test purposes, but please do not use it in production environments.
    • 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 CSS.

    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, then you will also find RTMP and UDP URLs in the Push URL area. Replace StreamName in your playback URL with the stream name used for push, and you can use the URL 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: The push domain name.
    • AppName: The live streaming application name, which is live by default and is customizable.
    • StreamName: The custom stream name used to identify a live stream.
    • txSecret: The authentication string generated after push authentication is enabled.
    • txTime: The expiration timestamp for the push URL.
    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, Java, and Go 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, Java, or Go.
      /**
      * 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: The authentication key.
      * time: The URL expiration time (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");

    See Also

    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