All Products
Search
Document Center

ApsaraVideo Live:Live stream recording

Last Updated:Jun 18, 2026

Live stream recording captures ingested streams and saves them to a specified storage location for post-broadcast playback. ApsaraVideo Live offers two storage options: store in ApsaraVideo VOD and store in OSS.

Feature overview

How it works

During live stream recording, the system processes the ingested live stream by segmenting it into Transport Stream (TS) files and packaging them into the target format, such as FLV, MP4, or M3U8. The final files are saved to your specified storage space.

Live stream recording only changes the container format of the audio and video. It does not alter the content at the encoding layer. If the source stream has issues such as video artifacts or audio-video desynchronization, the recorded file will retain these flaws.

Audio and video encoding formats

Because live stream recording first segments the live stream into TS files, the encoding format of the stream must be compatible with the TS container. ApsaraVideo Live supports only the following encoding formats:

  • Video codecs: H.264 (AVC), H.265 (HEVC), MPEG-4

  • Audio codecs: AAC, MP3

If the live stream contains audio or video encoded in other formats, you may encounter issues such as recording failure, a black screen in the recording, or no audio.

Storage method comparison

Live stream recording offers two storage options: ApsaraVideo VOD and OSS. You cannot configure both storage options for the same live stream. Please choose one based on your business requirements.

Item

Store in ApsaraVideo VOD

Store in OSS

Associated product

ApsaraVideo VOD

OSS

Storage format

  • M3U8 (default)

  • FLV

  • MP4

  • M3U8 (default)

  • FLV

  • MP4

  • CMAF

Recording post-processing

Supports media processing features such as auto merge and transcoding for recorded videos.

Requires manual processing.

Use cases

Ideal for post-production tasks on recorded content, such as clipping, transcoding, and composing.

Ideal for long-term storage and management of recorded content.

Recording trigger methods

Live stream recording can be triggered in four ways: automatic recording, on-demand recording, using ingest parameters, or manual recording.

Automatic recording

ApsaraVideo Live uses recording templates to manage recording configurations. The system matches an automatic recording template based on the DomainName, AppName, and StreamName in your ingest URL.

Matching logic

  • Exact match: In the recording template, specify a specific AppName and StreamName. This applies the template only to that specific live stream.

  • Wildcard match: In the recording template, set AppName to * to apply the template to all applications under the domain. Set StreamName to * to apply the template to all live streams within the application.

Callback confirmation

Use on-demand recording to dynamically decide whether to record a live stream based on your business rules.

Workflow:

  1. When a live stream starts, if the matching recording template is set to "On-demand recording", the live streaming service sends an HTTP request to your pre-configured on-demand callback URL to determine whether to record the stream.

  2. Your application receives the request and returns a recording command (allow or deny) based on its current business logic.

  3. The live streaming service starts the recording task based on your response.

You must first specify the on-demand callback URL for live stream recording in the event callback settings. For details on configuration, request parameters, and response format, see Live stream recording callbacks and On-demand recording callbacks.

Note:

The recording service processes your callback response to override template configurations:

  • Interval: Your provided Interval value will override the recording cycle configured in the recording template.

  • Format: The service calculates the intersection between your requested Format and the pre-configured formats in the recording template. If there are no common formats, the stream will not be recorded.

Ingest parameter trigger

When the trigger method is set to "Ingest parameter settings", you can control whether to enable recording for the current stream by using the record_config parameter in the ingest URL.

  • Parameter format: record_config={"NeedRecord": <true/false>}

  • Parameter description: true: Enables recording. false: Disables recording.

  • Note: The parameter must be URL-encoded when constructing the URL.

Assume that the stream ingest URL is: rtmp://push.example.com/live/stream1

If you need to enable recording by using parameters, you can construct the URL as follows: rtmp://push.example.com/live/stream1?record_config=%7B%22NeedRecord%22%3Atrue%7D&auth_key=xxx

Manual recording

For full control over the recording process based on your business logic, use manual recording.

At this point, you can call the RealTimeRecordCommand API to manually start recording a specific live stream.

This API also supports stopping a recording. You can call this interface to forcibly stop the current recording task, regardless of whether it was started automatically, on-demand, or manually.

Refer to the RealTimeRecordCommand API documentation, and use the command parameter to perform the start or stop operation.

Store recordings in ApsaraVideo VOD

Prerequisites

Activate the ApsaraVideo VOD service and configure a storage bucket. The bucket must be in the same region as the live center of the domain that you want to configure.

Configuration

ApsaraVideo Live uses recording templates to manage recording configurations. You can create a recording template to store recordings in ApsaraVideo VOD by using the console or an API.

Important

Recording must be configured before the live stream starts. Otherwise, the system does not retain the stream data. Make sure to complete the recording configuration before the stream goes live.

Method 1: Console

  1. Log on to the ApsaraVideo Live console.

  2. In the left navigation bar, select Feature Management > Recording. On the Recording Configuration tab, select VOD.

  3. Select the streaming domain to configure, and click Add.

  4. Configure the recording template.

    Basic recording settings

    Parameter

    Description

    Application Name

    The application name must be the same as the AppName in the stream ingestion URL to take effect. To apply this to all applications under the domain, enter *.

    Stream Name

    Stream name. Supports exact match to record a specific stream. To record all live streams under the current AppName, enter *.

    VOD Application

    The workspace where recorded files are stored, created in the ApsaraVideo VOD service. This field is not displayed if workspaces are not enabled.

    Bucket

    You can select a storage location created in the ApsaraVideo VOD service in the current region. By default, the system uses the default upload address configured in ApsaraVideo VOD.

    Recording Source

    You can record the Raw Stream or the Transcoded Streams. Both can be selected at the same time.

    When you select Transcoded Streams, you can specify up to 10 transcoding templates or select all transcoding templates.

    The transcoded stream recording can take effect only if the AppName of the transcoding template is * or is the same as the AppName of the recording template.

    Trigger Mode

    Recordings can be triggered in the following ways: Automatic, Callback Confirmation, Ingest Parameter Trigger, and Manual.

    For more information, see Recording trigger methods.

    Format

    Supports M3U8, FLV, and MP4 formats. When multiple formats are selected, you can configure VOD settings for each format separately.

    Recording Cycle

    The maximum duration of a single recording file. If the live stream duration exceeds this threshold, the system generates a new file. Default: 180 minutes. Range: 15 to 360 minutes.

    Reconnect Timeout

    If a live stream interruption is shorter than this duration, recording resumes to the same file. Longer interruptions cause a new file to be created. Default: 180 seconds. Range: 15 to 21,600 seconds.

    Segment Length

    The duration of a single TS segment. This is displayed only when you select the M3U8 format.

    Default: 30 seconds. Range: 5 to 30 seconds.

    VOD settings

    When storing recordings in ApsaraVideo VOD, you can use these settings to process the recorded files with ApsaraVideo VOD's media processing capabilities. If you select multiple recording formats, you can configure them separately.

    Parameter

    Description

    Auto Merge

    If enabled, multiple files from different recording cycles are automatically merged into a single recording file and stored in ApsaraVideo VOD after the live stream ends. The original recording files are retained.

    Video Processing

    Use the ApsaraVideo VOD service to process the recorded videos.

    Source Video: Each recording cycle file is processed individually.

    Merged Video: Processes the merged file (Displayed after auto merge is enabled).

    Processing Method

    SupportsTranscoding Template Group and Workflow.

    Processing Template

    Select a transcoding template group or workflow template from the ApsaraVideo VOD service.

    Note: You can only select templates created in the same region as the domain's live center.

    Category

    Set the category for the recorded file in the ApsaraVideo VOD service.

  5. Click OK to create a recording template.

Method 2: API

Call the AddLiveRecordVodConfig API to add a configuration for storing recordings in ApsaraVideo VOD. Sample code:

// Parameter settings for API request
AddLiveRecordVodConfigRequest.RecordFormat recordFormat0 = AddLiveRecordVodConfigRequest.RecordFormat.builder()
        .format("m3u8")
        .sliceDuration(30)
        .autoCompose("ON")
        .videoProcess("origin,compose")
        .processMethod("transcode")
        .processTemplateId("e2d796d3bb5fd8049d32bff62f94****")
        .tags("sports")
        .build();

AddLiveRecordVodConfigRequest addLiveRecordVodConfigRequest = AddLiveRecordVodConfigRequest.builder()
        .regionId("<Your RegionID>")
        .domainName("<Your DomainName>")
        .appName("live")
        .streamName("stream1")
        .cycleDuration(3600)
        .spaceId("app-1000000")
        .storageLocation("<Your StorageLocation>")
        .onDemand(0)
        .recordContent("raw,transcode")
        .delayTime(180)
        .recordFormat(java.util.Arrays.asList(recordFormat0))
        .transcodeTemplates(java.util.Arrays.asList("sd"))
        // Request-level configuration rewrite, can set Http request parameters, etc.
        // .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
        .build();

Key parameters

  • OnDemand

    The recording trigger method. Valid values: 0 (automatic recording), 1 (on-demand recording), 2 (ingest parameter settings), 7 (manual recording). For details, see Recording trigger methods.

  • DelayTime

    The splicing duration for interrupted streams in seconds. If a live stream interruption is shorter than this duration, recording resumes to the same file. Longer interruptions cause a new file to be created.

  • RecordContent, TranscodeTemplates

    Specify whether to record the source stream or a transcoded stream. When recording a transcoded stream, you must specify the transcoding template ID.

  • RecordFormat: Sets the storage format and VOD configuration. This includes:

    • AutoCompose: If enabled, multiple files from different recording cycles are automatically merged into a single file after the live stream ends.

    • VideoProcess, ProcessMethod, ProcessTemplateId: Use an ApsaraVideo VOD transcoding or workflow template to process the original recorded file or the auto-merged video.

For a complete parameter description, see AddLiveRecordVodConfig - Add a configuration to store live recordings in VOD.

Manage recordings

You can view recordings stored in ApsaraVideo VOD from the ApsaraVideo Live console and manage them using the ApsaraVideo VOD service.

  1. Log on to the ApsaraVideo Live console.

  2. In the left navigation bar, select Feature Management > Recording. Click the Recording Management tab.

  3. Select the configured streaming domain.

  4. Click the VOD tab.

    You can filter recording records by date range, AppName, and StreamName.

  5. To view and manage specific recording files, you can click Manage in the VOD Console in the Actions column, or log in to the ApsaraVideo VOD console and select Media Library > Audio/Video.

Store recordings in OSS

Prerequisites

  1. Activate the OSS service and create a storage bucket. The OSS bucket must be in the same region as the live center of the domain that you want to configure.

  2. Configure permissions for ApsaraVideo Live to write to OSS. This is usually authorized automatically when you activate the service. If you accidentally delete the permission, you can click Authorize Access to Cloud Resources to grant it again.

Important

We recommend that you use an Alibaba Cloud account to complete the authorization. If you use a RAM user, the user must have the following permissions: ram:CreateRole, ram:GetRole, ram:ListPoliciesForRole, and ram:AttachPolicyToRole. Granting these permissions to a RAM user poses security risks and is not recommended.

Configuration

ApsaraVideo Live uses recording templates to manage recording configurations. You can create a recording template to store recordings in OSS by using the console or an API.

After configuring the template, you must restart the ingest stream for the changes to take effect. To ensure a stream is recorded from the beginning, create the template before the stream starts.

Method 1: Console

  1. Log on to the ApsaraVideo Live console.

  2. In the left navigation bar, select Feature Management > Recording. On the Recording Configuration tab, select OSS.

  3. Select the streaming domain to configure, and click Add.

  4. Configure the recording template. You can choose to record the source stream, a transcoded stream, or both.

    Basic recording settings

    Parameter

    Description

    Application Name

    The application name. This must match the AppName in the push URL for the setting to take effect. If you want the setting to apply to all applications under the domain, enter *.

    Stream Name

    Stream name. You can specify an exact stream name to record a specific stream. To record all live streams under the current AppName, enter *.

    Storage Location

    You can select a bucket created in OSS in the current region.

    Note

    There are two types of storage buckets:

    • Standard bucket: Used for general file storage.

    • Media bucket: Dedicated to video transcoding. Files stored in this type of bucket can automatically trigger ApsaraVideo Media Processing (MPS) transcoding jobs.

    The system does not currently label bucket types. If you need to perform video transcoding, please keep a record of the media bucket name to ensure that transcoded files are stored correctly.

    Interruption Duration Threshold

    If a live stream interruption is shorter than this duration, recording resumes to the same file. Longer interruptions cause a new file to be created. Default: 180 seconds. Range: 15 to 21,600 seconds.

    Trigger Mode

    You can trigger recordings in the following ways: Automatic, Callback Confirmation, Ingest Parameter Trigger, and Manual.

    For more information, see Recording trigger methods.

    Record source stream

    Parameter

    Description

    Storage Format

    Supports M3U8, FLV, MP4, and CMAF formats. You can select multiple formats, but you cannot select M3U8 and CMAF at the same time.

    Naming Conventions

    The naming convention for recorded files. Default paths:

    M3U8, FLV, MP4:

    record/{AppName}/{StreamName}/{EscapedStartTime}_{EscapedEndTime}

    TS, fMP4:

    record/{AppName}/{StreamName}/{UnixTimestamp}_{Sequence}

    Segment Length

    The duration of a single TS segment. This is displayed only when you select the M3U8 or CMAF format.

    Default: 30 seconds. Range: 5 to 30 seconds.

    Recording Cycle

    The maximum duration of a single recording file. If the live stream duration exceeds this threshold, the system generates a new file. Default: 180 minutes. Range: 15 to 360 minutes.

    Record transcoded stream

    Parameter

    Description

    Transcoded Streams

    Select the transcoded streams to record. You can specify up to 10 transcoding templates or select all of them.

    For transcoded stream recording to work, the AppName of the transcoding template must be * or match that of the recording template.

    Storage Format

    Supports M3U8, FLV, MP4, and CMAF formats. You can select multiple formats, but you cannot select M3U8 and CMAF at the same time.

    Naming Conventions

    The naming convention for recorded files. Default paths:

    M3U8, FLV, MP4:

    transcodeRecord/{AppName}/{StreamName}_{TranscodingTemplateID}/{EscapedStartTime}_{EscapedEndTime}

    TS, fMP4:

    transcodeRecord/{AppName}/{StreamName}_{TranscodeTemplateID}/{UnixTimestamp}_{Sequence}

    Segment Length

    The duration of a single TS segment. This is displayed only when you select the M3U8 or CMAF format.

    Default: 30 seconds. Range: 5 to 30 seconds.

    Recording Cycle

    The maximum duration of a single recording file. If the live stream duration exceeds this threshold, the system generates a new file. Default: 180 minutes. Range: 15 to 360 minutes.

  5. Click OK to create the recording template.

Method 2: API

Call the AddLiveAppRecordConfig API to add a configuration for storing recordings in OSS. Sample code:

// Parameter settings for API request
AddLiveAppRecordConfigRequest.TranscodeRecordFormat transcodeRecordFormat0 = AddLiveAppRecordConfigRequest.TranscodeRecordFormat.builder()
        .sliceDuration(30)
        .sliceOssObjectPrefix("transcodeRecord/{AppName}/{StreamName}_{TranscodeTemplateID}/{UnixTimestamp}_{Sequence}")
        .ossObjectPrefix("transcodeRecord/{AppName}/{StreamName}_{TranscodeTemplateID}/{EscapedStartTime}_{EscapedEndTime}")
        .cycleDuration(900)
        .format("m3u8")
        .build();

AddLiveAppRecordConfigRequest.RecordFormat recordFormat0 = AddLiveAppRecordConfigRequest.RecordFormat.builder()
        .sliceDuration(30)
        .format("m3u8")
        .cycleDuration(900)
        .sliceOssObjectPrefix("record/{AppName}/{StreamName}/{UnixTimestamp}_{Sequence}")
        .ossObjectPrefix("record/{AppName}/{StreamName}/{Sequence}_{EscapedStartTime}_{EscapedEndTime}")
        .build();

AddLiveAppRecordConfigRequest addLiveAppRecordConfigRequest = AddLiveAppRecordConfigRequest.builder()
        .domainName("<Your DomainName>")
        .appName("live")
        .ossEndpoint("<Your OssEndpoint>")
        .ossBucket("<Your OssBucket>")
        .streamName("stream1")
        .onDemand(0)
        .delayTime(180)
        .recordFormat(java.util.Arrays.asList(recordFormat0))
        .transcodeRecordFormat(java.util.Arrays.asList(transcodeRecordFormat0))
        .transcodeTemplates(java.util.Arrays.asList("sd"))
        // Request-level configuration rewrite, can set Http request parameters, etc.
        // .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))
        .build();

Key parameters

  • OnDemand

    The recording trigger method. Valid values: 0 (automatic recording), 1 (on-demand recording), 2 (ingest parameter settings), 7 (manual recording). For details, see Recording trigger methods.

  • DelayTime

    The splicing duration for interrupted streams in seconds. If a live stream interruption is shorter than this duration, recording resumes to the same file. Longer interruptions cause a new file to be created.

  • RecordFormat

    The storage format and recording parameters for the source stream, including Format (storage format), OssObjectPrefix (naming convention), SliceDuration (segment duration), and CycleDuration (recording cycle).

  • TranscodeTemplates, TranscodeRecordFormat

    When recording a transcoded stream, specify the list of transcoding template IDs and the storage format and recording parameters for the transcoded stream.

For a complete parameter description, see AddLiveAppRecordConfig - Add a recording configuration.

Manage recordings

View recordings

You can view recordings stored in OSS in three ways:

Method 1: Console
  1. Log on to the ApsaraVideo Live console.

  2. In the left navigation bar, select Feature Management > Recording. Click the Recording Management tab.

  3. Select the configured streaming domain.

  4. Click the OSS tab.

    You can filter recording records by date range, AppName, and StreamName.

Method 2: API

ApsaraVideo Live provides an API to query all recording index files within a specific time period. ApsaraVideo Live stores index file information for only six months, limiting queries to data from this period. For API call details and parameter configuration, see DescribeLiveStreamRecordIndexFiles - Query all recording index files within a time period.

Method 3: OSS

When you configured the recording feature, you specified the storage location for the recording files in OSS. To view the files in OSS, see List objects.

Merge and extract content

When storing recordings in OSS, you can create a new index file to either extract a clip from a specific time period or merge multiple recording files into one.

Note

The recorded content must include the M3U8 storage format to be merged or extracted.

Method 1: Console
  1. Log on to the ApsaraVideo Live console.

  2. In the left navigation bar, select Feature Management > Recording. Select the Recording Management tab.

  3. Select the configured streaming domain.

  4. Select the OSS tab.

  5. Click Edit Index File. Filter the recording files by streaming domain, AppName, StreamName, and time range.

  6. You can view the time periods that contain recorded content in the timeline. Set the start and end times, and click Save As to save the newly generated M3U8 file.

Method 2: API

ApsaraVideo Live provides an API to create a new index file. TS segment information is stored in the ApsaraVideo Live system for only three months, so you can only select content recorded within the last three months.

For API call details and parameter configuration, see CreateLiveStreamRecordIndexFiles - Create recording index files.

Delete recordings

ApsaraVideo Live stores recording information, such as AppName, StreamName, and the OSS file storage path. The actual recording files are stored in OSS.

To delete files in OSS at the same time as you delete the recording information in ApsaraVideo Live, you must create the AliyunMTSVideoLifecycleRole service role and grant it the AliyunMTSVideoLifecycleRolePolicy system policy. You can click to authorize for one-click authorization.

You can delete recording files using the following methods:

  • Live console: On the Recording Management tab, select the file and delete it. Select Also delete the recording file stored in OSS to also delete the OSS file.

  • API: Call the DeleteLiveStreamRecordIndexFiles - Delete live stream recording files interface.

  • Direct OSS deletion: In general, we do not recommend directly deleting recording files from OSS. If your business requires it, see the OSS documentation on deleting objects.

  • Automatic deletion upon expiration: To enable this feature, submit a ticket to have the expiration time configured.

Configure a CDN domain

To accelerate the distribution of your recorded videos, configure a CDN domain. CDN distributes the videos to various nodes, allowing users to access content from the nearest node instead of the OSS origin. This improves access speed and saves on network costs. For specific operations, see Accelerate access to OSS by using Alibaba Cloud CDN.

Template priority policy

If you configure multiple recording templates and a live stream matches more than one, the system applies the one with the highest priority. A lower number indicates a higher priority.

Priority

DomainName

AppName

StreamName

1

Specified

Specified

Specified

2

Specified

Specified

*

3

Specified

*

*

("Specified" indicates that the corresponding parameter has a value and the value is not *)

Billing

Using the live stream recording feature may incur the following fees:

  • Monthly recording service fee

    After enabling live stream recording, you are billed based on the peak number of concurrent recording channels per month. For details, see Live stream recording fees.

  • Recording container format conversion fee

    When you select non-default formats like FLV, MP4, or CMAF, you are charged based on the duration. This fee is collected by the ApsaraVideo Live service. For details, see Live stream recording fees.

  • Recorded video processing fee

    When storing in ApsaraVideo VOD, processing recorded videos through auto merge or transcoding incurs video processing fees, which are charged by the ApsaraVideo VOD service. For details, see Editing and production billing and Media transcoding billing.

  • Storage Fees

    Storing recorded files in ApsaraVideo VOD incurs storage fees, which are charged by the ApsaraVideo VOD service. For details, see Media storage billing.

    Storing recorded files in OSS incurs storage fees, which are charged by the OSS service. For details, see Storage fees.

FAQ

Recording generation and availability

Generation mechanism

The recording file is not generated immediately after a stream disconnects. The system waits for the splicing duration for interrupted streams (default is 180 seconds). If the stream resumes within this period, the recording is appended to the existing file. If it does not resume, the system determines the stream has ended and generates the recording file.

You can adjust this duration based on your needs, but we recommend keeping the default setting. A shorter duration can lead to numerous small files due to network fluctuations, while a longer duration means a longer wait for the file after the stream ends.

Immediate generation

To generate the recording file immediately after a stream ends, without the splicing delay, set up an event callback for the ingest stream (see Event callbacks). When you receive the stream disconnection notification, call the RealTimeRecordCommand API to cancel the splicing delay.

realTimeRecordCommandRequest.setCommand("cancel_delay");

Viewing in-progress recordings

If a stream's duration has not exceeded the recording cycle, the file is typically generated after the stream ends. To access the current recording file before the stream ends, call the RealTimeRecordCommand API to refresh the recording. This command forcibly ends the current recording process, generates the file immediately, and then automatically starts a new recording.

realTimeRecordCommandRequest.setCommand("restart");

If your stream recording is configured with multiple storage formats, this operation will refresh all of them.

Impact of stream abnormalities on recording

The system handles stream abnormalities differently based on their severity:

  • Standard stream (meets encoding requirements with a stable frame rate and timestamp): Recordings are generated successfully 100% of the time.

  • Stream with minor issues (occasional frame rate fluctuations or timestamp jumps): The system automatically handles these for compatibility.

  • Stream with severe issues (prolonged absence of video frames, disordered timestamps, or missing keyframes): Recording success cannot be guaranteed.

Troubleshooting recording file issues

If recording files are not generated or contain unexpected content, check the following:

  • Recording configuration does not take effect — Recording templates only apply to new streams pushed after the configuration is completed. If a stream was already being pushed when the template was created, you must disconnect and re-push the stream for the template to take effect.

  • Transcoded stream is not recorded — Verify that the transcoding trigger method is set to "push-triggered". If the trigger method is set to "pull-triggered", the transcoded stream is generated only when a viewer actively pulls the stream. Without an active pull, the transcoded stream does not exist and therefore cannot be recorded.

  • Duplicate segments in playback — This typically occurs when a stream disconnects and reconnects within the splicing duration. The overlapping segments are both included in the recording. Post-production editing is required to remove the duplicate portions.

  • Blank screen with audio at high resolution — Check the following on the push side: whether the screen sharing source is being captured correctly, whether the encoder settings match the target resolution, and whether the player supports the encoding format. This issue is usually caused by the push-side configuration rather than the recording service.

  • No OSS callback records — Verify that the storage destination is set to OSS. ApsaraVideo VOD uses different callback events than OSS. If the recording is stored in ApsaraVideo VOD, check the ApsaraVideo VOD callback events instead.

  • Recording file name does not match expectations — When storing recordings in ApsaraVideo VOD, the recording file name defaults to the StreamName and does not support customization. If you need custom file names, use OSS storage and configure the naming convention in the recording template.