全部产品
Search
文档中心

ApsaraVideo Live:Hasilkan URL ingest dan streaming

更新时间:Jan 30, 2026

Untuk memulai siaran langsung, host memerlukan URL ingest untuk mendorong aliran, sedangkan penonton memerlukan URL streaming untuk pemutaran. Topik ini menjelaskan cara menghasilkan URL ingest dan streaming yang ditandatangani untuk ApsaraVideo Live. Anda akan mempelajari metode melalui Konsol untuk pengujian cepat serta pendekatan berbasis kode untuk lingkungan produksi.

Sebelum memulai

Sebelum menghasilkan URL, pastikan Anda telah:

  • Menambahkan dan mengaitkan domain ingest serta domain streaming di Konsol. Untuk petunjuknya, lihat Tambahkan domain.

  • Mengaktifkan URL signing untuk domain Anda.

Batas aliran bersamaan

Setiap domain ingest memiliki batas bawaan jumlah aliran bersamaan yang dapat didukung, tergantung pada wilayah pusat siaran langsung:

  • China (Beijing), China (Shanghai), China (Shenzhen): Maksimal 300 aliran

  • Wilayah lain: Maksimal 50 aliran.

Untuk informasi lebih lanjut, lihat Batas.

Struktur URL

URL siaran langsung standar terdiri dari lima komponen: protocol, domain name, AppName, StreamName, dan access token.

Format: {Protocol}://{Domain}/{AppName}/{StreamName}?auth_key={access_token}

image

Component

Description

Example

Protocol

Protokol streaming.

rtmp

Domain name

Domain ingest untuk mendorong aliran, atau domain streaming untuk pemutaran.

example.aliyundoc.com

AppName

Nama kustom untuk aplikasi Anda guna membedakan antara berbagai aplikasi atau skenario bisnis.

liveApp

StreamName

Nama kustom unik untuk siaran langsung.

liveStream

Access token

String terenkripsi yang dihasilkan menggunakan algoritma MD5 berdasarkan kunci autentikasi yang dikonfigurasi untuk domain Anda. Untuk detailnya, lihat URL signing.

1763451219-0-0-c9139**********08dcaf1dad8381

Hasilkan URL

Pilih salah satu metode berikut:

  • Hasilkan di Konsol: Cocok untuk uji coba dan pengujian. Hasilkan URL dengan sekali klik yang secara otomatis menyertakan access token terenkripsi.

  • Hasilkan melalui kode: Cocok untuk lingkungan produksi. Otomatiskan pembuatan URL di sisi server untuk manajemen dan distribusi yang fleksibel.

Hasilkan di konsol

  1. Buka halaman URL Generators.

  2. Konfigurasikan parameter berikut lalu klik Generate URLs.

    image

    Catatan

    Pembuat URL tidak mendukung pembuatan live subtitles stream URLs.

Hasilkan melalui kode

Langkah 1: Susun URI

Format URI dasar adalah {Protocol}://{Domain}/{AppName}/{StreamName}. Untuk contoh URL berbagai protokol, lihat Contoh URL ingest dan Contoh URL streaming.

// Pseudocode
protocol = "rtmp"
domain = "example.aliyundoc.com"
appName = "liveApp"
streamName = "liveStream"
uri = protocol + "://" + domain + "/" + appName + "/" + streamName
// Result: rtmp://example.aliyundoc.com/liveApp/liveStream

Langkah 2: Dapatkan kunci autentikasi

Ambil kunci autentikasi dari salah satu sumber berikut:

Catatan

Gunakan kunci domain ingest untuk URL ingest dan kunci domain streaming untuk URL streaming.

Langkah 3: Gabungkan URL yang ditandatangani

Contoh berikut menunjukkan cara menghasilkan access token dan menyusun URL lengkap menggunakan protokol RTMP.

Java

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class AuthDemo {
    private static String md5Sum(String src) {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        md5.update(StandardCharsets.UTF_8.encode(src));
        return String.format("%032x", new BigInteger(1, md5.digest()));
    }

private static String aAuth(String uri, String key, long exp) {
    String pattern = "^(rtmp://)?([^/?]+)(/[^?]*)?(\\\\?.*)?$";
    Pattern r = Pattern.compile(pattern);
    Matcher m = r.matcher(uri);
    String scheme = "", host = "", path = "", args = "";
    if (m.find()) {
        scheme = m.group(1) == null ? "rtmp://" : m.group(1);
        host = m.group(2) == null ? "" : m.group(2);
        path = m.group(3) == null ? "/" : m.group(3);
        args = m.group(4) == null ? "" : m.group(4);
    } else {
        System.out.println("NO MATCH");
    }

    String rand = "0";  // "0" by default, other value is ok
    String uid = "0";   // "0" by default, other value is ok
    String sString = String.format("%s-%s-%s-%s-%s", path, exp, rand, uid, key);
    String hashValue = md5Sum(sString);
    String authKey = String.format("%s-%s-%s-%s", exp, rand, uid, hashValue);
    if (args.isEmpty()) {
        return String.format("%s%s%s%s?auth_key=%s", scheme, host, path, args, authKey);
    } else {
        return String.format("%s%s%s%s&auth_key=%s", scheme, host, path, args, authKey);
    }
}

public static void main(String[] args) {
    // The ingest or streaming URL to be signed. example.aliyundoc.com is the ingest or streaming domain, liveApp is the AppName, and liveStream is the StreamName.
    // Ingest and streaming URLs use the same signing method.
    // The AppName or StreamName can be up to 256 characters long and can contain digits, letters, hyphens (-), underscores (_), and equal signs (=).
    String uri = "rtmp://example.aliyundoc.com/liveApp/liveStream";  
    // The authentication key. To generate ingest URLs, use the key of the ingest domain. To generate streaming URLs, use the key of the streaming domain.
    String key = "<input private key>";                       
    // exp is a UNIX timestamp in seconds. The URL's final expiration time is this timestamp plus the validity period configured for URL signing on the domain.
    // For example, if you set exp to the current time + 3600 seconds, the final expiration time is the current time + 3600 seconds + the validity period. If you set exp to the current time, the final expiration time is the current time + the validity period. 
    long exp = System.currentTimeMillis() / 1000 + 1 * 3600;  
    String authUri = aAuth(uri, key, exp);                    
    System.out.printf("URL : %s\nAuth: %s", uri, authUri);
}
}

Python

import re
import time
import hashlib
import datetime
def md5sum(src):
    m = hashlib.md5()
    if isinstance(src, str):
        src = src.encode('utf-8')
    m.update(src)
    return m.hexdigest()
    
def a_auth(uri, key, exp):
    p = re.compile("^(rtmp://)?([^/?]+)(/[^?]*)?(\\?.*)?$")
    if not p:
        return None
    m = p.match(uri)
    scheme, host, path, args = m.groups()
    if not scheme: scheme = "rtmp://"
    if not path: path = "/"
    if not args: args = ""
    rand = "0"      # "0" secara default, nilai lain boleh digunakan
    uid = "0"       # "0" secara default, nilai lain boleh digunakan
    sstring = "%s-%s-%s-%s-%s" %(path, exp, rand, uid, key)
    hashvalue = md5sum(sstring.encode('utf-8'))
    auth_key = "%s-%s-%s-%s" %(exp, rand, uid, hashvalue)
    if args:
        return "%s%s%s%s&auth_key=%s" %(scheme, host, path, args, auth_key)
    else:
        return "%s%s%s%s?auth_key=%s" %(scheme, host, path, args, auth_key)
def main():
    # URL ingest atau streaming yang akan ditandatangani. example.aliyundoc.com adalah domain ingest atau streaming, liveApp adalah AppName, dan liveStream adalah NamaStream.
    # URL ingest dan streaming menggunakan metode penandatanganan yang sama.
    # AppName atau NamaStream dapat memiliki panjang hingga 256 karakter dan dapat berisi digit, huruf, tanda hubung (-), garis bawah (_), dan tanda sama dengan (=).
    uri = "rtmp://example.aliyundoc.com/liveApp/liveStream"  
    # Kunci otentikasi. Untuk membuat URL ingest, gunakan kunci dari domain ingest. Untuk membuat URL streaming, gunakan kunci dari domain streaming.
    key = "<input private key>"                         
    # exp adalah stempel waktu UNIX dalam detik. Waktu kedaluwarsa akhir URL adalah stempel waktu ini ditambah periode validitas yang dikonfigurasi untuk Penandatanganan URL pada domain.
    # Misalnya, jika Anda mengatur exp ke waktu saat ini + 3600 detik, waktu kedaluwarsa akhir adalah waktu saat ini + 3600 detik + periode validitas. Jika Anda mengatur exp ke waktu saat ini, waktu kedaluwarsa akhir adalah waktu saat ini + periode validitas. 
    exp = int(time.time()) + 1 * 3600                   
    authuri = a_auth(uri, key, exp)                     
    print("URL : %s\nAUTH: %s" %(uri, authuri))
if __name__ == "__main__":
    main()

Go

package main
import (
    "crypto/md5"
    "encoding/hex"
    "fmt"
    "regexp"
    "time"
)

func md5sum(src string) string {
    h := md5.New()
    h.Write([]byte(src))
    return hex.EncodeToString(h.Sum(nil))
}

func a_auth(uri, key string, exp int64) string {
    p, err := regexp.Compile("^(rtmp://)?([^/?]+)(/[^?]*)?(\\?.*)?$")
    if err != nil {
        fmt.Println(err)
        return ""
    }
    m := p.FindStringSubmatch(uri)
    var scheme, host, path, args string
    if len(m) == 5 {
        scheme, host, path, args = m[1], m[2], m[3], m[4]
    } else {
        scheme, host, path, args = "rtmp://", "", "/", ""
    }
    rand := "0" // "0" by default, other value is ok
    uid := "0"  // "0" by default, other value is ok
    sstring := fmt.Sprintf("%s-%d-%s-%s-%s", path, exp, rand, uid, key)
    hashvalue := md5sum(sstring)
    auth_key := fmt.Sprintf("%d-%s-%s-%s", exp, rand, uid, hashvalue)
    if len(args) != 0 {
        return fmt.Sprintf("%s%s%s%s&auth_key=%s", scheme, host, path, args, auth_key)
    } else {
        return fmt.Sprintf("%s%s%s%s?auth_key=%s", scheme, host, path, args, auth_key)
    }
}

func main() {
    // The ingest or streaming URL to be signed. example.aliyundoc.com is the ingest or streaming domain, liveApp is the AppName, and liveStream is the StreamName.
    // Ingest and streaming URLs use the same signing method.
    // The AppName or StreamName can be up to 256 characters long and can contain digits, letters, hyphens (-), underscores (_), and equal signs (=).
    uri := "rtmp://example.aliyundoc.com/liveApp/liveStream" 
    // The authentication key. To generate ingest URLs, use the key of the ingest domain. To generate streaming URLs, use the key of the streaming domain.
    key := "<input private key>"     
    // exp is a UNIX timestamp in seconds. The URL's final expiration time is this timestamp plus the validity period configured for URL signing on the domain.
    // For example, if you set exp to the current time + 3600 seconds, the final expiration time is the current time + 3600 seconds + the validity period. If you set exp to the current time, the final expiration time is the current time + the validity period.
    exp := time.Now().Unix() + 3600                                    
    authuri := a_auth(uri, key, exp)                                       
    fmt.Printf("URL : %s\nAUTH: %s", uri, authuri)
}

PHP

<?php
function a_auth($uri, $key, $exp) {
    preg_match("/^(rtmp:\/\/)?([^\/?]+)?(\/[^?]*)?(\?.*)?$/", $uri, $matches);
    $scheme = $matches[1];
    $host = $matches[2];
    $path = $matches[3];
    $args = $matches[4];
    if  (empty($args)) {
        $args ="";
    }
    if  (empty($scheme)) {
        $scheme ="rtmp://";
    }
    if  (empty($path)) {
        $path ="/";
    }
    $rand = "0";
    // "0" by default, other value is ok
    $uid = "0";
    // "0" by default, other value is ok
    $sstring = sprintf("%s-%u-%s-%s-%s", $path, $exp, $rand, $uid, $key);
    $hashvalue = md5($sstring);
    $auth_key = sprintf("%u-%s-%s-%s", $exp, $rand, $uid, $hashvalue);
    if ($args) {
        return sprintf("%s%s%s%s&auth_key=%s", $scheme, $host, $path, $args, $auth_key);
    } else {
        return sprintf("%s%s%s%s?auth_key=%s", $scheme, $host, $path, $args, $auth_key);
    }
}
// The ingest or streaming URL to be signed. example.aliyundoc.com is the ingest or streaming domain, liveApp is the AppName, and liveStream is the StreamName. 
// Ingest and streaming URLs use the same signing method. 
// The AppName or StreamName can be up to 256 characters long and can contain digits, letters, hyphens (-), underscores (_), and equal signs (=).
$uri = "rtmp://example.aliyundoc.com/liveApp/liveStream";
// The authentication key. To generate ingest URLs, use the key of the ingest domain. To generate streaming URLs, use the key of the streaming domain.
$key = "<input private key>";
// exp is a UNIX timestamp in seconds. The URL's final expiration time is this timestamp plus the validity period configured for URL signing on the domain.
// For example, if you set exp to the current time + 3600 seconds, the final expiration time is the current time + 3600 seconds + the validity period. If you set exp to the current time, the final expiration time is the current time + the validity period. 
$exp = time() + 3600;
$authuri = a_auth($uri, $key, $exp);
echo "URL :" . $uri;
echo PHP_EOL;
echo "AUTH:" . $authuri;
?>

C#

using System;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
using System.Text;
public class Test
{
    public static void Main()
    {
        // The ingest or streaming URL to be signed. example.aliyundoc.com is the ingest or streaming domain, liveApp is the AppName, and liveStream is the StreamName.
        // Ingest and streaming URLs use the same signing method.
        // The AppName or StreamName can be up to 256 characters long and can contain digits, letters, hyphens (-), underscores (_), and equal signs (=).
        string uri= "rtmp://example.aliyundoc.com/liveApp/liveStream";  
        // The authentication key. To generate ingest URLs, use the key of the ingest domain. To generate streaming URLs, use the key of the streaming domain.
        string key= "<input private key>";                           
        DateTime dateStart = new DateTime(1970, 1, 1, 8, 0, 0);
        // exp is a UNIX timestamp in seconds. The URL's final expiration time is this timestamp plus the validity period configured for URL signing on the domain.
        // For example, if you set exp to the current time + 3600 seconds, the final expiration time is the current time + 3600 seconds + the validity period. If you set exp to the current time, the final expiration time is the current time + the validity period. 
        string exp  = Convert.ToInt64((DateTime.Now - dateStart).TotalSeconds+3600).ToString(); 
        string authUri = aAuth(uri, key, exp);
        Console.WriteLine (String.Format("URL :{0}",uri));
        Console.WriteLine (String.Format("AUTH :{0}",authUri));
    }
    public static string aAuth(string uri, string key, string exp)
    {
        Regex regex = new Regex("^(rtmp://)?([^/?]+)(/[^?]*)?(\\\\?.*)?$");
        Match m = regex.Match(uri);
        string scheme = "rtmp://", host = "", path = "/", args = "";
        if (m.Success)
        {
            scheme=m.Groups[1].Value;
            host=m.Groups[2].Value;
            path=m.Groups[3].Value;
            args=m.Groups[4].Value;
        }else{
            Console.WriteLine ("NO MATCH");
        }
        string rand = "0";  // "0" by default, other value is ok
        string uid = "0";   // "0" by default, other value is ok
        string u = String.Format("{0}-{1}-{2}-{3}-{4}",  path, exp, rand, uid, key);
        string hashValue  = Md5(u);
        string authKey = String.Format("{0}-{1}-{2}-{3}", exp, rand, uid, hashValue);
        if (args=="")
        {
            return String.Format("{0}{1}{2}{3}?auth_key={4}", scheme, host, path, args, authKey);
        } else
        {
            return String.Format("{0}{1}{2}{3}&auth_key={4}", scheme, host, path, args, authKey);
        }
    }
    public static string Md5(string value)
    {
        MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
        byte[] bytes = Encoding.ASCII.GetBytes(value);
        byte[] encoded = md5.ComputeHash(bytes);
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<encoded.Length; ++i)
        {
            sb.Append(encoded[i].ToString("x2"));
        }
        return sb.ToString();
   }
}

Contoh URL ingest

Protocol

Example

Description

RTMP

rtmp://{Domain}/{AppName}/{StreamName}?auth_key={access_token}

Protokol standar untuk ingest siaran langsung.

ARTC

artc://{Domain}/{AppName}/{StreamName}?auth_key={access_token}

URL ingest untuk Real-Time Streaming (RTS).

SRT

srt://{Domain}:1105?streamid=#!::h={Domain},r=/{AppName}/{StreamName}?auth_key={access_token},m=publish

Protokol SRT dinonaktifkan secara default. Untuk mengaktifkannya, lihat SRT stream ingest.

Contoh URL streaming

URL type

Description

Protocol

Example address

Standard streaming URL

Jika Anda menggunakan SRT untuk ingest aliran, pemutaran didukung melalui RTMP, FLV, HLS, dan ARTC.

RTMP

rtmp://{Domain}/{AppName}/{StreamName}?auth_key={access_token}

FLV

http://{Domain}/{AppName}/{StreamName}.flv?auth_key={access_token}

HLS

http://{Domain}/{AppName}/{StreamName}.m3u8?auth_key={access_token}

ARTC

artc://{Domain}/{AppName}/{StreamName}?auth_key={access_token}

Transcoded stream URL (Default transcoding atau custom transcoding)

Tambahkan _{transcoding_template_ID} ke StreamName.

Untuk mendapatkan ID templat transkoding, konfigurasikan live stream transcoding.

RTMP

rtmp://{Domain}/{AppName}/{StreamName}_{transcoding_template_ID}?auth_key={access_token}

FLV

http://{Domain}/{AppName}/{StreamName}_{transcoding_template_ID}.flv?auth_key={access_token}

HLS

http://{Domain}/{AppName}/{StreamName}_{transcoding_template_ID}.m3u8?auth_key={access_token}

ARTC

artc://{Domain}/{AppName}/{StreamName}_{transcoding_template_ID}?auth_key={access_token}

Transcoded stream URL (Multi-bitrate transcoding)

Untuk aliran bitrate adaptif, tambahkan _{transcoding_template_group_ID} ke StreamName dan tambahkan parameter aliyunols=on ke URL.

Untuk mendapatkan transcoding template group ID, konfigurasikan live stream transcoding.

HLS

http://{Domain}/{AppName}/{StreamName}_{transcoding_template_group_ID}.m3u8?aliyunols=on&auth_key={access_token}

Delayed stream URL

Untuk aliran tertunda, tambahkan -alidelay ke StreamName.

Sebelum menggunakan aliran tertunda untuk pemutaran, konfigurasikan stream delay.

RTMP

rtmp://{Domain}/{AppName}/{StreamName}-alidelay?auth_key={access_token}

FLV

http://{Domain}/{AppName}/{StreamName}-alidelay.flv?auth_key={access_token}

HLS

http://{Domain}/{AppName}/{StreamName}-alidelay.m3u8?auth_key={access_token}

ARTC

artc://{Domain}/{AppName}/{StreamName}-alidelay?auth_key={access_token}

Live subtitles stream URL

Tambahkan _{subtitle_template_name} ke StreamName.

Untuk membuat templat subtitel, konfigurasikan live subtitles.

RTMP

rtmp://{Domain}/{AppName}/{StreamName}_{subtitle_template_name}?auth_key={access_token}

FLV

http://{Domain}/{AppName}/{StreamName}_{subtitle_template_name}.flv?auth_key={access_token}

HLS

http://{Domain}/{AppName}/{StreamName}_{Csubtitle_template_name}.m3u8?auth_key={access_token}

Verifikasi URL yang dihasilkan

Untuk memverifikasi URL yang dihasilkan, kami menyarankan menggunakan aplikasi demo di perangkat seluler untuk ingest aliran dan pemutar media VLC di PC untuk pemutaran. Untuk metode ingest dan streaming lainnya, lihat Live stream ingest dan Live stream playback.

Verifikasi URL ingest:

  1. Unduh aplikasi demo ApsaraVideo Live dengan memindai kode QR di perangkat seluler (Android atau iOS).

    image

    Catatan

    Di perangkat iOS, Anda mungkin menerima pesan bahwa demo berasal dari developer enterprise yang tidak tepercaya. Buka Settings > General > VPN & Device Management, temukan izin yang diperlukan oleh Taobao, lalu ketuk Trust.

  2. Buka aplikasi demo. Pilih Camera Pushing atau Screen Sharing. Masukkan URL ingest. Jika Anda menghasilkan URL di Konsol, pindai kode QR untuk mengisi otomatis URL tersebut.

    imageimage

  3. Klik Start.

    Verifikasi bahwa aliran muncul di halaman Stream Management. Jika tidak, periksa apakah Anda telah mengikuti langkah-langkah sebelumnya dengan benar.

    image

Verifikasi URL streaming:

Catatan

Pastikan klien ingest tetap berjalan. Jika tidak, pemutaran akan gagal.

  1. Unduh dan instal VLC media player.

  2. Jalankan VLC media player.

  3. Pada bilah menu, pilih Media > Open Network Stream.

  4. Pada tab Network, masukkan URL streaming yang dihasilkan. Contoh: rtmp://pull-singapore.cloud-example.net/ziji/test?auth_key=1750150177-0-0-9b7d7e8b3431acc543a99c69********

    p888206

Troubleshooting

Jika Anda mengalami masalah selama ingest atau pemutaran aliran, gunakan troubleshooting tool untuk memvalidasi URL dan informasi autentikasi.