All Products
Search
Document Center

ApsaraVideo Live:Live stream recording

Last Updated:Aug 01, 2023

ApsaraVideo Live provides the live stream recording feature that allows you to record live streams in real time and play historical streams. This topic describes the live stream recording feature in detail.

Overview

You can use the live stream recording feature to record live streams, manage index files, manage recordings, and configure recording callbacks.

  • Record live streams

    • Scenario

      ApsaraVideo Live uses streaming URLs to play streams that are ingested by the stream ingest client in real time. To replay or modify the content that was streamed, you must use the live stream recording feature.

    • Description

      The live stream recording feature allows you to record ingested streams in a live center, encapsulates the recorded streams by using HTTP Live Streaming (HLS), and then stores the encapsulated streams in the specified location. The streams can be stored in the M3U8, MP4, and FLV formats. If the M3U8 format is used, TS segments are generated.

      You can store the recorded streams in ApsaraVideo VOD or an Object Storage Service (OSS) bucket. If you store the recorded streams in ApsaraVideo VOD, you can manage the streams by using the online editing, media asset management, and playback control features that are provided by ApsaraVideo VOD.

    • How to record live streams

      For more information, see How to record live streams.

  • Manage index files

    Note

    You can manage index files only if you store the live streams in an OSS bucket.

    • Scenario

      ApsaraVideo Live generates TS segments during live streaming and generates M3U8 playlists 180 seconds after stream ingest ends. The M3U8 playlists contain indexes of the entire stream ingest process. You cannot configure the index range. To resolve this issue, ApsaraVideo Live provides the index management feature that allows you to manage M3U8 playlists.

    • Description

      ApsaraVideo Live automatically generates an index file each time a stream ingest process ends. You can specify the recording start time and end time to configure the index range. The index management feature allows you to view and edit index files.

      • View index files: You can view existing index files. Index files include the index files that are automatically generated 180 seconds after each stream ingest process ends and the custom index files that you create.

      • Edit index files: You can edit existing index files to generate new index files. A new index file may be a combination of existing index files or a part of an existing index file.

    • How to manage index files

      For more information, see How to manage index files.

  • Manage recordings

    • Description

      • You can view and manage recordings.

      • You can delete recordings that expire.

        You can specify a validity period for recordings that are stored. This way, ApsaraVideo Live automatically deletes the recordings that expire.

        Note

        By default, this feature is unavailable to users. To use this feature, attach the AliyunMTSVideoLifecycleRolePolicy policy and submit a ticket. For more information about how to submit a ticket, see Contact us.

    • How to manage recordings

      For more information, see How to manage recordings.

  • Configure recording callbacks

    • Description

      The callbacks for live stream recording include recording status callbacks and file generation callbacks.

      • Recording status callbacks: invoked when recording starts or ends. The callback message notifies you that recording starts or ends.

      • File generation callbacks: invoked when recordings are generated. The callback message contains the name, start time, end time, and duration of a recording.

    • How to configure recording callbacks

      For more information, see Callbacks for live stream recording.

Recording rules

  • Recording rules are configured based on the AppName parameter of an ingested stream. You can configure a recording rule for all ingested streams of a specific application. If the AppName parameter is set to an asterisk (*), the recording rule applies to all ingested streams under the specified domain name. The value of the AppName parameter for a recording rule must be the same as the AppName parameter that is specified for the ingested stream. You can also configure a recording rule for a single stream.

    Note

    If recording rules based on the AppName parameter and for a single stream are configured, the recording rule that is configured for a single stream takes precedence.

  • A recording rule takes effect for live streams that are ingested after the recording rule is configured. For a stream that is being ingested, interrupt the stream and then resume it 180 seconds later.

  • If you store recorded streams in ApsaraVideo VOD, all generated M3U8 playlists and TS segments are stored in the specified bucket that is used to store input media assets in ApsaraVideo VOD. For more information, see Add media buckets.

  • If you store recorded streams in an OSS bucket, make sure that the OSS bucket is created in advance. The OSS bucket must reside in the same region as the live center of the domain name. Cross-region recording is not supported.

  • Recorded streams that have the same stream names in the same application cannot be stored in ApsaraVideo VOD and an OSS bucket at the same time.

How to record live streams

Storage location

Procedure

Console operations

API operation

ApsaraVideo VOD

Preparation: Activate ApsaraVideo VOD.

Activate ApsaraVideo VOD

N/A

Configure the recording settings:

  1. Create a live-to-VOD recording template.

  2. Create a storage rule in ApsaraVideo VOD.

  1. Store live recordings in ApsaraVideo VOD

  2. Configure transcoding settings

AddLiveRecordVodConfig

Manage the recorded streams by using the online editing, media asset management, and playback control features that are provided by ApsaraVideo VOD.

Console overview

List of operations by function

OSS

Preparations: Complete the OSS configurations by performing the following steps:

  1. Create an OSS bucket.

  2. Obtain the write permissions on the OSS bucket.

  3. Configure a domain name for CDN.

Configure OSS

N/A

Configure the recording settings:

Configure recording information.

Store recording files in OSS

AddLiveAppRecordConfig

The following sample code provides an example on how to use the server SDK for Java to configure recording settings for an application:

AddLiveAppRecordConfigRequest addLiveAppRecordConfigRequest = new AddLiveAppRecordConfigRequest();
addLiveAppRecordConfigRequest.setDomainName("<DomainName>");
addLiveAppRecordConfigRequest.setAppName("<AppName>");
addLiveAppRecordConfigRequest.setOssEndpoint("<Endpoint>");
addLiveAppRecordConfigRequest.setOssBucket("<BucketName>");
addLiveAppRecordConfigRequest.setOssObjectPrefix("<ObjectPrefix>");
try {
    AddLiveAppRecordConfigResponse addLiveAppRecordConfigResponse = client.getAcsResponse(addLiveAppRecordConfigRequest);
    System.out.println(addLiveAppRecordConfigResponse.getRequestId());
    // todo something.
} catch (ServerException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (ClientException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}        
Note

For more information about the server SDK for Java, see Use the server SDK for Java.

How to manage index files

Item

Console operations

API operation

View index files

To view index files, log on to the ApsaraVideo Live console and choose Streaming Management > Recordings. Then, click the OSS tab.

Index files include the index files that are automatically generated 180 seconds after each stream ingest process ends and the custom index files that you create.

Edit index files

For more information, see Manage recordings.

CreateLiveStreamRecordIndexFiles

How to manage recordings

You can view and manage recordings in the ApsaraVideo Live console.

  • Recordings that are stored in ApsaraVideo VOD

    • For more information about how to view and manage a recording in the ApsaraVideo Live console, see Manage recordings.

    • To view and manage a recording in the ApsaraVideo VOD console, perform the following steps:

      1. Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Media Files > Audio/Video.

      2. Select a recording that is stored in ApsaraVideo VOD and click Manage in the Actions column.

      3. On the Basic Information tab, view or edit the basic information about the recording, such as the name, description, category, tag, and thumbnail. After you complete the configuration, click Save.

  • Recordings that are stored in OSS

    • For more information about how to view and manage a recording in the ApsaraVideo Live console, see Manage recordings.

    • Recordings are stored in an OSS bucket based on specific rules. You can find the folder where a recording is stored in the OSS console and copy the streaming URL of the recording. To view and manage a recording in the OSS console, perform the following steps:

      1. Log on to the OSS console. In the left-side navigation pane, click Buckets. Then, click the name of the bucket where the recording is stored.

      2. Click Files and select the folder where the recording is stored.

        The complete recording and the TS segments are stored in the record/{AppName}/{StreamName} path.

      3. Select the recording that you want to view and click View Details in the Actions column to obtain the streaming URL of the recording.

You can also call the DescribeLiveStreamRecordContent operation to query the information about a recording.

Note

You can call OSS API operations to manage the lifecycle of a recording that is stored in an OSS bucket.

If you want expired recordings that are stored in an OSS bucket to be automatically deleted, you must obtain the permissions. To do so, click Agree to Authorization on the Cloud Resource Access Authorization page. Then, submit a ticket. The after-sales team configures a validity period for recordings based on your business requirements. For more information about how to submit a ticket, see Contact us. If a recording expires, ApsaraVideo Live automatically deletes the recording.

Note

In this step, you are assigned the role that grants ApsaraVideo Live the permissions to access Alibaba Cloud resources. If you delete the role by accident, you can be assigned the role again on the Cloud Resource Access Authorization page.