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

  • Record live streams
    • Scenarios

      ApsaraVideo Live uses streaming URLs to play the streams that are pushed by the stream pushing client in the form of live streams. To replay or modify the content that has been streamed, you must use the live stream recording feature.

    • Feature description

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

      The live stream recording feature allows you to store the recorded streams to ApsaraVideo VOD or an Object Storage Service (OSS) bucket. If you store the recorded streams to 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 to an OSS bucket.
    • Scenarios

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

    • Feature description
      ApsaraVideo Live automatically generates an index file each time a stream pushing process ends. You can specify the recording start time and end time to customize the index range. The index management feature allows you to view and edit index files.
      • View index files: You can view existing index files. The index files include the index files that are automatically generated 180 seconds after each stream pushing process ends, and the custom index files that you create.
      • Edit index files: You can edit existing index files to generate a new index file. The generated 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
    • Feature description
      • View and manage recordings
      • Delete the recordings that expire

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

        Note To use this feature, you must be assigned the AliyunMTSVideoLifecycleRolePolicy role in the RAM console and submit a ticket to apply for permissions.
    • How to manage recordings

      For more information, see How to manage recordings.

  • Configure recording event callbacks
    • Feature description

      The callbacks for live stream recording include callbacks that are fired to obtain the information about recording statuses and recordings.

      • Callbacks for recording statuses: fired when recording starts and ends. The callback message notifies you that recording starts or ends.
      • Callbacks for recordings: fired when recordings are generated. The callback message contains the name of a recording, the start time and end time of the recording, and the recording duration.
    • How to configure recording event callbacks

      For more information, see Callbacks for live stream recording.

Recording rules for live streams

  • Recording rules for live streams are configured based on the AppName parameter of pushed streams. You can configure a recording rule for all pushed streams of a specific application. If the AppName parameter is set to an asterisk (*), the recording rule applies to all pushed streams of the specified live domain. The value of the AppName parameter of a pushed stream must be the same as that in the recording configuration. You can also configure a recording rule for a single stream.
    Note Assume that recording rules are configured based on the AppName parameter and for a single stream. In this case, the recording rule that is configured for a single stream prevails.
  • The recording configuration takes effect for live streams that are pushed after you complete the configuration. To record a stream that is being pushed, interrupt the stream and then resume it 180 seconds later.
  • If you store the recorded streams to 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 that you select when you add the domain. Cross-region recording is not supported.
  • Recorded streams that have same stream names in the same application cannot be stored to ApsaraVideo VOD and an OSS bucket at the same time.

How to record live streams

Storage location Procedure Operation in the ApsaraVideo Live console API operation
ApsaraVideo VOD Preparation: Activate ApsaraVideo VOD. Get started with ApsaraVideo VOD N/A
Set the recording configurations:
  1. Create a live-to-VOD recording template.
  2. Create a storage rule in ApsaraVideo VOD.
  1. Store live recordings in ApsaraVideo VOD
  2. Manage 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 bucket Preparations: Complete the OSS configurations by performing the following steps:
  1. Create an OSS bucket.
  2. Obtain write permissions on the OSS bucket.
  3. Configure a domain name for CDN.
Configure OSS N/A
Set the recording configurations:

Configure recording information.

Note
  • To automatically record transcoded streams, submit a ticket to enable transcoded stream recording. Submit the information that is needed for recording, such as the file name extension of transcoded files. You cannot call the AddLiveAppRecordConfig operation to set the configurations for recording transcoded streams. In this case, the stream name can be specified or not specified. If you have specified a stream name, a file name extension does not need to be added to the specified stream name.
  • To record transcoded streams in a custom manner, call the AddLiveAppRecordConfig operation to configure a recording template and set the OnDemand parameter to 7. Then, submit a ticket to enable transcoded stream recording. After that, call the RealTimeRecordCommand operation to manage the start and end of recording. In this case, you must specify the stream name and add a file name extension to the stream name.
Store live recordings in OSS AddLiveAppRecordConfig
The following sample code shows how to use the SDK for Java to add recording configurations for a live streaming application:
        IClientProfile profile = DefaultProfile.getProfile("cn-shagnhai","<AccessKeyId>", "<AccessKeyScret>");
        IAcsClient client = new DefaultAcsClient(profile);
        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();
        }        

How to manage index files

Operation Operation in the ApsaraVideo Live console API operation
View index files. To view index files, log on to the ApsaraVideo Live console and click Recordings under Stream Management. Then, click the OSS tab.

The index files include the index files that are automatically generated 180 seconds after each stream pushing 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.

  • Files that are stored to 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, click Audio/Video under Media Files.
      2. Select the recording that you have stored to ApsaraVideo VOD and click Manage on the right.
      3. On the Basic Information tab, view or edit the basic information of the recording, such as the name, description, category, tag, and thumbnail. After you complete the configuration, click Save.
  • Files that are stored to an OSS bucket
    • For more information about how to view and manage a recording in the ApsaraVideo Live console, see Manage recordings.
    • Recordings are stored to 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 files are stored in the record/{AppName}/{StreamName} path.

      3. Select the recording that you want to view and click View Details on the right 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.
To delete the recordings that expire, you must be assigned a specific role by performing the following steps, and then submit a ticket:
  1. Log on to the RAM console.
  2. In the left-side navigation pane, click RAM Roles.
  3. Click Create RAM Role, set the Trusted entity type parameter to Alibaba Cloud Service, and then click Next.
  4. In the Configure Role step:
    • Set the Role Type parameter to Normal Service Role.
    • Set the RAM Role Name parameter to AliyunMTSVideoLifecycleRole. Make sure that the name is accurate.
    • Set the Select Trusted Service parameter to Media Transcoding Service.

    Click OK.

  5. In the Finish step, click Input and Attach.
  6. In the Add Permissions dialog box, add permissions by performing the following operations.
    • Set the Type parameter to System Policy.
    • Set the Policy Name parameter to AliyunMTSVideoLifecycleRolePolicy.

    Click OK.

  7. Submit a ticket. After you submit a ticket, the after-sales team configures a validity period for recordings based on your requirements. If a recording expires, ApsaraVideo Live automatically deletes the recording.