tencent cloud


Push Configuration

Last updated: 2023-10-07 11:55:10
    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.


    CSS provides a test domain name xxxx.tlivepush.com. You can use it to push streams for test purposes, but the test domain should not be used in production environments.
    A push URL is valid before the expiration time you specify. After it expires, you need to generate a new URL.


    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.
    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


    1. Go to Domain Management, click the target domain name or click Manage on its right to enter the details page.
    2. Select Push Configuration and, in Push Address Generator, complete the following settings:
    2.1 Select an expiration time, such as 2022-11-24 16:00:35.
    2.2 Enter a custom stream name (StreamName).
    2.3 Click Generate Push Address to generate a push URL containing the StreamName.
    3. If you haven’t enabled authentication for your push domain, then you will also find RTMP, WebRTC, SRT, and RTMP over SRT 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:
    Parameter description
    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.
    If you have enabled authentication, txTime indicates the expiration time of the URL.
    For the sake of convenience, the console allows you to specify the URL expiration time in human-readable format. If you enable authentication, when generating push URLs, the system will convert it to a hex timestamp (the value of txTime).
    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");
    package com.test;
    import java.io.UnsupportedEncodingException;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    public class Test {
    public static void main(String[] args) {
    System.out.println(getSafeUrl("txrtmp", "11212122", 1469762325L));
    private static final char[] DIGITS_LOWER =
    {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    * KEY+ streamName + txTime
    private static String getSafeUrl(String key, String streamName, long txTime) {
    String input = new StringBuilder().
    String txSecret = null;
    try {
    MessageDigest messageDigest = MessageDigest.getInstance("MD5");
    txSecret = byteArrayToHexString(
    } catch (NoSuchAlgorithmException e) {
    } catch (UnsupportedEncodingException e) {
    return txSecret == null ? "" :
    new StringBuilder().
    private static String byteArrayToHexString(byte[] data) {
    char[] out = new char[data.length << 1];
    for (int i = 0, j = 0; i < data.length; i++) {
    out[j++] = DIGITS_LOWER[(0xF0 & data[i]) >>> 4];
    out[j++] = DIGITS_LOWER[0x0F & data[i]];
    return new String(out);
    package a
    import (
    func GetPushUrl(domain, streamName, key string, time int64)(addrstr string){
    var ext_str string
    if key != "" && time != 0{
    txTime := strings.ToUpper(strconv.FormatInt(time, 16))
    txSecret := md5.Sum([]byte(key + streamName + txTime))
    txSecretStr := fmt.Sprintf("%x", txSecret)
    ext_str = "?txSecret=" + txSecretStr + "&txTime=" + txTime
    addrstr = "rtmp://" + domain + "/live/" + streamName + ext_str
    *domain: 123.test.com
    *streamName: streamname
    *key: 69e0daf7234b01f257a7adb9f807ae9f
    *time: 2022-04-26 14:57:19 CST
    func main(){
    domain, streamName, key := "123.test.com", "streamname", "69e0daf7234b01f257a7adb9f807ae9f"
    //CST: ChinaStandardTimeUT, "2006-01-02 15:04:05 MST" must be const
    t, err := time.Parse("2006-01-02 15:04:05 MST", "2022-04-26 14:57:19 CST")
    if err != nil{
    fmt.Println("time transfor error!")
    fmt.Println(GetPushUrl(domain, streamName, key, t.Unix()))
    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