All Products
Search
Document Center

ApsaraVideo Live:Get started with co-streaming

Last Updated:Feb 26, 2024

Co-streaming is a typical scenario of interactive streaming. This topic describes how to get started with co-streaming.

Prerequisites

  • An Alibaba Cloud account is created and real-name verification is complete. To create an Alibaba Cloud account, visit the Alibaba Cloud official website. For more information, see Create an Alibaba Cloud account.

  • An ingest domain and a streaming domain are available. ICP filing for the domain names is complete. For more information, see the ICP Filing documentation.

    Note
    • If you are in a live center outside the Chinese mainland and set Acceleration Region to Outside Chinese Mainland for the domain names, ICP filing is not required.

    • If the ingest domain and the streaming domain are second-level domain names under the same top-level domain name, you need to apply for an ICP number only for the top-level domain name.

Activate ApsaraVideo Live

  1. Log on to the Alibaba Cloud official website and go to the ApsaraVideo Live product page. Click Activate Now.

  2. On the page that appears, click Activate.

  3. On the ApsaraVideo Live buy page, select Pay-By-Traffic or Pay-By-Peak-Bandwidth as the metering method, tick I have read and agree to ApsaraVideo Live Terms of Service, and click Activate Now. Then, you can use the ApsaraVideo Live console.

Add an ingest domain and a streaming domain

To use ApsaraVideo Live services, you must add an ingest domain and a streaming domain.

Note

You can view the tutorial video to learn how to add a domain name. For more information, see Add a domain name.

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, click Domains. The Domain Management page appears.

  3. Click Add Domain.

  4. Configure the domain name based on your business requirements.

    配置域名

    Parameter

    Option

    Description

    Domain Type

    • Streaming Domain

    • Ingest Domain

    The type of the domain name. You can add an ingest domain or a streaming domain. This parameter cannot be modified once set.

    Note
    • To add an ingest domain, select Ingest Domain for Domain Type. To add a streaming domain, select Streaming Domain for Domain Type.

    • You cannot add a domain name as both an ingest domain and a streaming domain.

    Domain Name

    N/A

    Enter the domain name that you want to accelerate. Take note of the following points:

    • In most cases, use a subdomain as an accelerated domain name. Example: demo.aliyundoc.com.

    • ApsaraVideo Live does not support wildcard domain names, such as *.aliyundoc.com.

    • Duplicate accelerated domain names are not allowed. If the error message The specified domain already exists is displayed, check whether the domain name is added to other cloud services such as ApsaraVideo VOD, Dynamic Route for CDN (DCDN), Secure CDN (SCDN), or Video Surveillance System.

    • After you activate ApsaraVideo Live, you can add up to 20 domain names to ApsaraVideo Live for each Alibaba Cloud account. If the average daily peak bandwidth of your domain names exceeds 50 Mbit/s, you can submit a ticket to increase the quota of domain names. Make sure that the quota increase does not incur business risks. For more information about how to submit a ticket, see Contact us.

    • Content that is served from the domain name must comply with the limits of ApsaraVideo Live. For more information, see Verify a domain name.

    Note

    The specified subdomain must belong to the same Alibaba Cloud account. When you add a subdomain, ApsaraVideo Live verifies the ownership of the subdomain. If the subdomain belongs to a different account, an error message appears.

    Acceleration Region

    Chinese Mainland

    • For an ingest domain, if the streamers are located in the Chinese mainland, select Chinese Mainland.

    • For a streaming domain, if the viewers are located in the Chinese mainland, select Chinese Mainland.

    Apply for an ICP filing from the Ministry of Industry and Information Technology of China (MIIT) for the domain name. We recommend that you use the Alibaba Cloud ICP Filing system.

    Global

    • For an ingest domain, if the streamers are located in the Chinese mainland, Hong Kong (China), Macao (China), Taiwan (China), and other countries and regions, select Global.

    • For a streaming domain, if the viewers are located in the Chinese mainland, Hong Kong (China), Macao (China), Taiwan (China), and other countries and regions, select Global.

    Apply for an ICP filing from the MIIT for the domain name. We recommend that you use the Alibaba Cloud ICP Filing system.

    Outside Chinese Mainland

    • For an ingest domain, if the streamers are located in countries and regions outside the Chinese mainland, including Hong Kong (China), Macao (China), and Taiwan (China), select Outside Chinese Mainland.

    • For a streaming domain, if the viewers are located in countries and regions outside the Chinese mainland, including Hong Kong (China), Macao (China), and Taiwan (China), select Outside Chinese Mainland.

    • If you select Outside Chinese Mainland and the live center is located outside the Chinese mainland, you do not need to apply for an ICP filing for the domain name.

    • If you select Outside Chinese Mainland and the live center is located in the Chinese mainland, you must apply for an ICP filing for the domain name. We recommend that you apply for an ICP filing by using the Alibaba Cloud ICP Filing system.

    Note

    For more information about how to select the acceleration region, see How do I select the acceleration region for a domain name? .

    Live Center

    N/A

    A live center provides media processing features for live streams in the cloud, such as snapshot capture, recording, transcoding, and production studio.

    The live center of an ingest domain must be located in the same region as that of the associated streaming domain. This parameter cannot be modified once set.

    For more information about how to select a live center, see How do I select a live center? .

  5. Click Next.

Add CNAME records

To enable acceleration for ApsaraVideo Live, you must add CNAME records at your DNS service provider to map your ingest domain and streaming domain to the CNAME that is assigned by ApsaraVideo Live. The following example shows how to add a CNAME record when your DNS service provider is Alibaba Cloud. For information about how to add a CNAME record at other DNS service providers, see Add a CNAME record.

Note
  • You can view the tutorial video to learn how to add a CNAME record. For more information, see Add a CNAME record.

  • The server that Alibaba Cloud CDN uses to resolve the CNAME of a domain name is deployed in the Chinese mainland. If you configure region-specific DNS settings for your domain name, for example, you add a CNAME record for your domain name in regions outside the Chinese mainland, including Hong Kong (China), Macao (China), and Taiwan (China), the domain name cannot be mapped to the CNAME. The status of the CNAME is Pending Configuration in the Alibaba Cloud CDN console. However, CDN acceleration for the domain name is not affected.

  • CNAMEs that are assigned by Alibaba Cloud CDN, DCDN, ApsaraVideo Live, and ApsaraVideo VOD can be used only for domain name resolution. If Alibaba Cloud detects that your CNAME is used for unauthorized or malicious activities, Alibaba Cloud reserves the right to close your Alibaba Cloud account and remove the domain names.

  1. Log on to the Alibaba Cloud DNS console.

  2. In the left-side navigation pane, click Domain Name Resolution. The Domain Name Resolution page appears.

  3. Find the domain name for which you want to add a CNAME record and click DNS Settings in the Actions column.

  4. Click Add DNS Record and configure the parameters that are described in the following table.001

    Parameter

    Description

    Record Type

    Select CNAME from the drop-down list.

    Hostname

    Specify a prefix for the domain name. For more information about regular prefixes of domain names and sample domain names, see the following table.

    DNS Request Source

    Use the default value.

    Record Value

    Enter the CNAME that you obtained.

    TTL Period

    Use the default value.

    Prefix

    Sample domain name

    Description

    demo

    demo.aliyundoc.com

    The subdomain name.

    @

    aliyundoc.com

    The root domain name.

    *

    *.aliyundoc.com

    The wildcard domain name.

  5. Click OK.

To check whether a CNAME record takes effect, run the ping <domain name> or dig <domain name> command. If the CNAME that is returned is the same as the CNAME that is assigned to the domain name in the ApsaraVideo Live console, the CNAME record is in effect.002

Associate the streaming domain with the ingest domain

ApsaraVideo Live uses the edge ingest method. To ingest and play streams, you must associate the streaming domain with the ingest domain.

Note

You can view the tutorial video to learn how to associate a streaming domain with an ingest domain. For more information, see Associate a streaming domain with an ingest domain.

  1. On the Domain Management page, find the streaming domain that you added and click Domain Settings in the Actions column. The Streaming Management > Basic Settings page appears.

  2. Click the Basic Information tab.

    On this tab, you can view the CNAME, Added At, Domain Type, Live Center, Edge Group, and Quota Limits information. Basic Information

    Note
    • You can manage quotas of ApsaraVideo Live only in the China (Beijing), China (Shanghai), China (Shenzhen), and Singapore regions. To increase quotas for other centers, submit a ticket. For more information, see Contact us.

    • For more information about quota limits, see Manage ApsaraVideo Live quotas.

    • For more information about how to change the edge group, see Change the edge group.

  3. Click the Stream Ingest Information tab.

  4. Click Add Stream Ingest Information or the Edit icon next to Ingest Domain and select the ingest domain that you want to associate.

Create an interactive streaming application

  1. Log on to the ApsaraVideo Live console.

  2. In the left-side navigation pane, choose Scenario-based Services > Interactive Streaming > Applications.

  3. On the Applications page, click Create Application.image.png

  4. Enter a custom name in the Instance Name field, tick Terms of Service, and then click Buy Now.

  5. After the application is created, refresh the Applications page to view the application.

    Note

    By default, no fees are incurred when you create an application. You are charged based on your actual usage in the cloud. For more information, see Billing of interactive streaming.

Configure stream relay

Note

In co-streaming scenarios, you need to configure global single-stream relay to ApsaraVideo Live and specify a streaming domain for viewers in the live room. This way, the stream of the streamer is relayed to ApsaraVideo Live by default and played in the live room for viewers to watch. After co-streaming is started, the stream of the streamer and the stream of the co-streamer are mixed by calling the stream mixing method provided by the SDK. Then, the mixed stream is ingested to viewers.

  1. In the left-side navigation pane, choose Scenario-based Services > Interactive Streaming > Applications.

  2. Find the application that you created and click Manage in the Actions column.

  3. Click Stream Relay tab. In the Global Stream Relay to ApsaraVideo Live section, turn on Stream Relay. In the dialog box that appears, configure the stream relay parameters.

    • Streaming Domain: Select a streaming domain that is relayed for standard streaming. You can play live streams, configure transcoding and recording settings, and perform other operations based on the streaming domain.

      Important

      Do not enable RTS 2.0 for the streaming domain. Otherwise, relayed stream pulling fails.

    • AppName: the application name in the streaming URL after stream relay. Default value: live. You can specify a custom application name.

      Note

      If you need to configure templates such as transcoding, recording, and snapshot templates for the relayed stream, you must specify an application name that is the same as the application name specified in the templates for them to take effect.

    • SEI Insertion: uses supplemental enhancement information (SEI) to insert basic user information such as the UID and mixed-stream layout parameters into streams. This way, in co-streaming scenarios, when the layout for stream mixing and relay changes, the application which viewers use to watch streams can parse the layout information from SEI in real time. This helps facilitate the adjustment of interaction styles. For more information, see SEI format.

      • Insert SEI at Regular Intervals: This option lets you insert SEI at a specified interval from 1,000 to 5,000 ms.

      • Insert SEI in I-frames: This option lets you insert SEI in I-frames of a video stream.

Configure HTTPS settings and HTTP header settings for the streaming domain

If some of the viewers require playback on the web, you need to configure HTTPS secure acceleration and allow cross-origin requests for the streaming domain. For more information about how to configure HTTPS secure acceleration, see Configure HTTPS secure acceleration.

For more information about how to configure the Access-Control-Allow-Origin header to allow cross-origin requests, see Configure HTTP headers.

Generate ingest and streaming URLs for co-streaming

You can generate the ingest and streaming URLs of the streamer and co-streamer and the CDN streaming URL of viewers by using the ApsaraVideo Live console, or construct these URLs by using the concatenation rules.

Method 1: Generate the URLs by using the console

You can use the URL generator in the ApsaraVideo Live console to generate the ingest and streaming URLs of the streamer and co-streamer and the CDN streaming URL of viewers. For more information, see Co-streaming URL generator.

Method 2: Construct the URLs

Tokens in ingest and streaming URLs of the streamer and co-streamer that are generated by using the console are temporary, and are usually used for testing.

If you need ingest and streaming URLs that are used for business purposes, construct the URLs by using the concatenation rules for security reasons. Tokens in URLs that you construct by using the concatenation rules are calculated based on the SdkAppID, AppKey, room ID, UserID, and timestamp by using the SHA-256 encryption algorithm. This prevents malicious parties from forging a token to gain access to your cloud services. For more information about the concatenation rules, see Ingest and streaming URLs of streamers and co-streamers in co-streaming scenarios and CDN streaming URLs of viewers.