ApsaraVideo Live recording can record the current live stream in real-time and enable historical playback. This topic describes the ApsaraVideo Live recording feature.
Function introduction
ApsaraVideo Live plays data from the ingest source in the form of real-time streams. If you want to watch the content again after the live stream ends, you must use the live stream recording feature.
Live stream recording is the process of recording streaming data received by the live center and saving it to your specified storage location. Currently, two methods are provided for live stream recording storage: Recording Stored In VOD and Recording Stored In OSS.
How live stream recording works
The process of live stream recording is to pull the live stream that you push, encapsulate the audio and video into individual media segments (with TS as the container format), and then store them. The live stream recording feature complies with the following principles:
Live stream recording only modifies the container format of audio and video (converting RTMP/FLV to TS) and never modifies the audio and video content (i.e., the content at the coding layer). For example, if the live stream you push has a distorted screen, the recorded content will also have a distorted screen.
Live stream recording has permission to write recording files to the user's storage address, but it does not have permission to modify/delete task files (including the recorded files that have been written) in the user's storage address. The recording files in the user's storage address are completely managed by you.
Using the live stream recording feature will incur recording service fees. The default recording file format is TS/M3U8. If transcoding and container format conversion processing is required, recording container format conversion fees will be incurred. For billing rules, see Live Stream Recording Fees.
Conditions
Audio and video encoding formats
ApsaraVideo Live needs to segment live streams into TS files first. Therefore, the audio and video encoding formats of the live streams that you ingest must meet the requirements of the TS container format. Based on the FLV and ISO/IEC 13818-1 standards, the live stream recording feature currently supports the following encoding formats:
Video: H.264, HEVC, and MPEG-4
Audio: AAC and MP3
If the live stream contains audio and video encoded in formats other than those mentioned above, the following issues may occur during live stream recording: failure to generate recording files, black screen recordings, recordings without sound, and other unforeseen abnormal situations.
Abnormal stream processing mechanism
Standard stream (meets encoding requirements with stable frame rate/timestamp) ✅ 100% normal generation of recording files
Minor abnormal stream (occasional frame rate fluctuation/timestamp jump) ✅ System automatically handles for compatibility
Critical abnormal stream (long-term absence of video frames/disordered timestamps/missing keyframes) ❌ Recording success rate cannot be guaranteed
Feature comparison
You can store the recordings of a live stream in ApsaraVideo VOD or OSS. These two methods are suitable for different scenarios. You can choose a storage method based on your business requirements.
Storage method | Associated products and services | Supported recording methods | Container format | Scenarios |
Record and store to VOD | Activate ApsaraVideo VOD |
|
| Tends to focus on post-production of recorded content, emphasizing post-processing such as video editing, playback, setting thumbnails for recorded videos, etc. |
Recordings stored in OSS | Activate OSS |
|
| You want to focus on the management and storage of recordings. |
The same live stream Cannot Simultaneously be configured with two storage methods.
Live stream recording first segments the live stream into individual TS segments, and then combines them into recording files with the corresponding container format. Encapsulation into formats other than TS/M3U8 will incur container format conversion fees.
Automatic recording rules
You can specify a domain name, AppName, or StreamName to record all applications under a domain name, all live streams under an application, or precisely record a specific live stream. AppName and StreamName can be set to *, which represents all AppNames and all StreamNames.
You can configure multiple recording templates that specify recordings to store in OSS or VOD. However, if a live stream can match multiple recording templates at the same time, the recording templates take effect based on priority. The following describes the priority levels (a lower numeric value indicates a higher priority):
Priority | Domain name | AppName | StreamName |
1 | The Secret generated when the application is created. | The Secret generated when the application is created. | ✓ |
2 | The Secret generated when the application is created. | ✓ | * |
3 | ✓ | * | * |
A check mark (✓) indicates that the parameter has a value other than an asterisk (*) in the recording rule that you configure in the console or by calling an API operation. An asterisk (*) indicates that the parameter value is an asterisk (*).
Record and store to VOD
Prerequisites
If you use the recording storage to VOD method to configure the live stream recording feature, you need to activate ApsaraVideo VOD service, and configure Manage storage buckets.
Recording files are stored in ApsaraVideo VOD, which incurs storage fees. For billing in VOD, see Basic service billing of video-on-demand.
When you enable the VOD bucket, make sure that the VOD bucket resides in the same region as the live center of the streaming domain.
You cannot configure the Live-to-VOD feature by using a Finance Cloud account.
Feature configuration
ApsaraVideo Live provides two methods to configure recording storage to VOD.
After you configure the recording settings, you must re-ingest the stream for the configuration to take effect.
After a live stream is interrupted for 180 seconds, a recording file is generated for the live stream.
Method one: Console configuration
- Log on to the ApsaraVideo Live console.
In the left-side navigation pane, select Feature Management > Live Stream Recording to go to the Live Stream Recording page, and then select the Store To VOD Configuration tab.
Select the streaming domain that you want to configure, and click Add.
Configure the recording template.
The parameters and descriptions of the recording template are shown in the following table.
Parameters
Description
AppName
The application name of the video. The AppName you enter must be consistent with the AppName of the stream ingest to take effect. If you want to record at the domain name level, you can enter an asterisk (*).
StreamName
You can store the recording files of a specific live stream in ApsaraVideo VOD. You only need to enter the specified stream name. If you want to record all streams, which means recording all streams under the AppName, you can enter an asterisk (*).
NoteAppName and StreamName parameters support English letters, numbers, "-", and "_" characters, with a length limit of 255 characters.
Storage Address
Select a storage location.
Recording Cycle
Recording Cycle is the maximum duration after the current live stream is converted to a video-on-demand file. The range is 15 to 360 minutes, with a maximum recording time of 6 hours. If the recording exceeds 6 hours, the system generates a new file based on the recording naming convention. The default ts segment length is 30 seconds.
Recording Transcoding Template
Select a storage transcoding rule from the drop-down list. You can transcode the recorded videos in the video-on-demand service. You can transcode the videos to different formats or retain the original quality without transcoding.
Recording and transcoding template operations, please see ApsaraVideo VOD transcoding configuration.
NoteThe region of the transcoding template that you use in ApsaraVideo VOD must be the same as the region of your domain name. For example, if your domain name resides in the China (Shanghai) region, the transcoding template that you use in ApsaraVideo VOD must also reside in the China (Shanghai) region.
Auto Merge Switch
After you enable this feature, multiple recording cycle files can be automatically merged into one recording file and stored in VOD after the live stream recording ends.
NoteAfter you enable the auto merging of recording files of multiple cycles, the editing and production feature and the transcoding feature of ApsaraVideo VOD are required. For billing details, see Billing of editing and production and Billing of media transcoding.
Custom Merge Transcoding Template
Select a transcoding template from the drop-down list, which is obtained from the current video-on-demand system. The system performs transcoding on the automatically merged video in the video-on-demand service based on the settings of the transcoding template. For more information about operations on automatic merge transcoding templates, see Transcoding templates.
NoteThe region of the transcoding template that you use in ApsaraVideo VOD must be the same as the region of your domain name. For example, if your domain name resides in the China (Shanghai) region, the transcoding template that you use in ApsaraVideo VOD must also reside in the China (Shanghai) region.
Click OK.
Method 2: API configuration
Call the AddLiveRecordVodConfig - Add live stream recording to video-on-demand configuration interface to add configuration. The SDK call reference is as follows:
//Replace the content in angle brackets with actual values
DefaultProfile profile = DefaultProfile.getProfile("", "", "");
IAcsClient client = new DefaultAcsClient(profile);
AddLiveRecordVodConfigRequest addLiveRecordVodConfigRequest=new AddLiveRecordVodConfigRequest();
addLiveRecordVodConfigRequest.setDomainName("");
addLiveRecordVodConfigRequest.setAppName("");
addLiveRecordVodConfigRequest.setStreamName("");
addLiveRecordVodConfigRequest.setVodTranscodeGroupId("VOD_NO_TRANSCODE");
//The address of the VOD bucket.
addLiveRecordVodConfigRequest.setStorageLocation("");
AddLiveRecordVodConfigResponse addLiveRecordVodConfigResponse = null;
try {
addLiveRecordVodConfigResponse = client.getAcsResponse(addLiveRecordVodConfigRequest);
} catch (ClientException e) {
e.printStackTrace();
}
System.out.println(new Gson().toJson(addLiveRecordVodConfigResponse));
The preceding sample code indicates that a recording storage configuration to VOD is set for the <DomainName> domain name, with AppName as <AppName> and StreamName as <StreamName>. The recorded content is not transcoded (VOD_NO_TRANSCODE) and is stored in the video-on-demand system bucket <StorageLocation>.
AppName and StreamName configuration details can be found in: Automatic recording rules.
Recording content transcoding
Recording is stored in VOD in m3u8 format. If you want to store it in other formats, you can configure the Recording Transcoding Template.
addLiveRecordVodConfigRequest.setVodTranscodeGroupId("");
The transcoding template needs to be configured in the video-on-demand system. For more information, see Transcoding template.
The Video-on-demand System Transcoding Template Group ID configured for the.
After you configure transcoding, the recording files are transcoded (the original files are retained) and the transcoded stream URLs are generated.
Merge recorded content
Recording management
Recordings stored in OSS
Prerequisites
If you use the recording storage to OSS method to configure the live stream recording feature, you need to activate OSS service and create a bucket. For more information, see Configure OSS.
Recording files stored in OSS will incur storage fees. For billing in OSS, see Storage fees.
The OSS bucket must reside in the same region as the live center of the domain to be configured.
Feature configuration
ApsaraVideo Live provides two methods to add configurations for storing recordings in OSS.
After you configure the recording settings, you must ingest the stream again for the configuration to take effect.
Stream interruption that exceeds the stream splicing duration (default 180 seconds) generates a recording file.
Method one: Console configuration
- Log on to the ApsaraVideo Live console.
In the left-side navigation pane, select Feature Management > Live Stream Recording to go to the Live Stream Recording page, and then select the Store To OSS Configuration tab.
Select the streaming domain that you want to configure, and click Add.
Configure the recording template.
Table 1. Recording template parameters
Parameters
Description
AppName
The application name of the video. The AppName you enter must be consistent with the AppName in the ingest URL for the configuration to take effect. If you want to record at the domain name level, you can enter an asterisk (*).
StreamName
You can store the recordings of a specific live stream in OSS by specifying the stream name. If you want to record all streams, which means recording all streams under the AppName, you can enter an asterisk (*).
NoteAppName and StreamName parameters support English letters, numbers, hyphens (-), and underscores (_). The length is limited to 255 characters.
The asterisk (*) can only be entered separately and cannot be used as a wildcard character in a string.
Storage Location
Select a storage location.
NoteStorage buckets are classified into two types:
Standard bucket: Used for regular file storage
Media Bucket: Dedicated to video transcoding processing. Files stored in this type of bucket automatically trigger MPS transcoding jobs.
The current system does not identify or distinguish Bucket types. If you need to execute video transcoding, please record the media Bucket name you use to ensure the accurate storage location of the transcoded media files.
Stream Splicing Duration
If the stream interruption duration exceeds the specified duration, a new file is generated. The stream interruption duration ranges from 15 to 21600 seconds.
Storage Format
Supports four formats: FLV, M3U8, MP4, and CMAF.
NoteSelect at least one storage format. You cannot select the CMAF and M3U8 formats at the same time.
Storage Rules
The default storage path is: record/{AppName}/{StreamName}/{EscapedStartTime}_{EscapedEndTime}.
Sample command:
AppName is liveApp****, StreamName is liveStream****, and the storage path for recording in m3u8 format is record/liveApp****/liveStream****/{EscapedStartTime}_{EscapedEndTime }.
Single TS Duration
The length of a single segment. Default value: 30 seconds. The length of a TS segment can range from 5 to 30 seconds.
Recording Cycle
Recording Cycle ranges from 15 minutes to 360 minutes, with a maximum recording duration of 6 hours. If the recording exceeds 6 hours, the system will generate a new file according to the recording naming convention.
NoteThe recording cycle specifies the maximum length of a video-on-demand file that is converted from the current live stream.
Configure recording transcoding stream. (Optional)
ImportantWhen you use the live stream transcoding feature, you are charged based on the transcoding standard, resolution, and total length of transcoded streams. For more information about billing rules, see Live Stream Transcoding Fees.
Table 2. Recording transcoding stream parameters
Parameters
Description
Recording Transcoding Stream
Open the Record And Transcode Stream switch and configure the parameters.
Storage Format
Supports four formats: FLV, M3U8, MP4, and CMAF.
NoteSelect at least one storage format. You cannot select the CMAF and M3U8 formats at the same time.
Storage Rule
The default storage path is: transcodeRecord/{AppName}/{StreamName}/{EscapedStartTime}_{EscapedEndTime}.
Sample command:
AppName is liveApp****, StreamName is liveStream****, Transcoding Template ID is lld, and the actual storage path when recording in m3u8 format is transcodeRecord/liveApp****/liveStream****_lld/{EscapedStartTime}_{EscapedEndTime}.
Single TS Duration
The length of a single segment. Default value: 30 seconds. The length of a TS segment can range from 5 to 30 seconds.
Recording Cycle
Recording Cycle ranges from 15 minutes to 360 minutes, with a maximum recording duration of 6 hours. If the recording exceeds 6 hours, the system generates a new file based on the recording naming convention.
NoteThe recording cycle specifies the maximum length of a VOD file that is converted from the current live stream.
Transcoding Template ID
You can select specific transcoding templates (up to 10) or all transcoding templates.
The AppName of the transcoding template must be consistent with the recording template to take effect. If there is no transcoding template, you need to add one first. For more information, see default transcoding.
Click OK.
Method 2: API configuration
Call the AddLiveAppRecordConfig - Add recording configuration API to add a configuration. The SDK call reference is as follows:
//Replace the content in angle brackets with actual values
DefaultProfile profile = DefaultProfile.getProfile("", "", "");
IAcsClient client = new DefaultAcsClient(profile);
AddLiveAppRecordConfigRequest addLiveAppRecordConfigRequest=new AddLiveAppRecordConfigRequest();
addLiveAppRecordConfigRequest.setAppName("");
addLiveAppRecordConfigRequest.setStreamName("");
addLiveAppRecordConfigRequest.setDomainName("");
addLiveAppRecordConfigRequest.setOssEndpoint("");
addLiveAppRecordConfigRequest.setOssBucket("");
List formatList=new ArrayList();
AddLiveAppRecordConfigRequest.RecordFormat m3u8Format=new AddLiveAppRecordConfigRequest.RecordFormat();
m3u8Format.setFormat("m3u8");
//The naming format of a recording to store in OSS.
m3u8Format.setOssObjectPrefix("");
//The naming format of a segment.
m3u8Format.setSliceOssObjectPrefix("");
formatList.add(m3u8Format);
addLiveAppRecordConfigRequest.setRecordFormats(formatList);
AddLiveAppRecordConfigResponse addLiveAppRecordConfigResponse = null;
try {
addLiveAppRecordConfigResponse = client.getAcsResponse(addLiveAppRecordConfigRequest);
} catch (ClientException e) {
e.printStackTrace();
}
System.out.println(new Gson().toJson(addLiveAppRecordConfigResponse));
The above example code indicates that for the <DomainName> domain name, the configuration for recording storage to OSS is set with AppName as <AppName>, StreamName as <StreamName>, storage format as m3u8, and storage location in <OssBucket>.
can be viewed through the region to which belongs in OSS OSS regions and endpoints.
AppName and StreamName configuration details can be found in: Automatic recording rules.
Recording and transcoding stream
If you want to reduce the size of recording files when storing recorded content, you can achieve this by recording transcoded streams (adjusting video bitrate, increasing video compression rate, and reducing file size while ensuring video quality). The feature of storing recordings to OSS supports storing both transcoded and original streams simultaneously, and also supports storing only transcoded streams or original streams.
When you use the live stream transcoding feature, you are charged based on the transcoding standard, resolution, and total length of transcoded streams. For more information about billing rules, see Live Stream Transcoding Fees.
Custom recording policy
In Feature configuration, we configured the live stream recording feature. When stream ingest starts, the system begins to record the live content. We call this Automatic Recording.
In some cases, you may want to determine whether to record a live stream based on your business requirements. The live stream recording feature provides methods to address this issue. You can determine whether to record a live stream in the following scenarios:
The Live Center calls back to query whether your business system needs to record the live content. Recording starts only after receiving a response confirming the need for recording. We call this On-demand Recording.
Your business system sends notifications to the live streaming service to record the live content. We call this Manual Recording.
On-demand recording
To implement on-demand recording, your business system needs to provide a URL address for live service invocation. For more information, see On-demand recording callback.
The following sample code provides an example on how to configure on-demand recording:
//Set the OnD//Set the OnDemand parameter to 1 to enable on-demand recording through HTTP callbacks.
addLiveAppRecordConfigRequest.setOnDemand(1);
Simultaneously call the AddLiveRecordNotifyConfig - Add domain-level recording callback configuration API to configure recording callbacks.
Manual recording
To enable manual recording, you must disable the automatic recording feature. The following sample code provides an example:
//Set the OnDemand parameter to 7 to disable automatic recording.
addLiveAppRecordConfigRequest.setOnDemand(7);
Then during the live streaming, you can call the RealTimeRecordCommand - Real-time recording instruction API to start recording based on your business requirements.
Stop recording
Whether it is Automatic Recording, On-demand Recording, or Manual Recording, you can call the RealTimeRecordCommand - Real-time recording instruction API to actively stop recording.
//Replace the content in angle brackets with actual values
RealTimeRecordCommandRequest realTimeRecordCommandRequest=new RealTimeRecordCommandRequest();
realTimeRecordCommandRequest.setCommand("stop");
realTimeRecordCommandRequest.setAppName("");
realTimeRecordCommandRequest.setStreamName("");
realTimeRecordCommandRequest.setDomainName("");
RealTimeRecordCommandResponse realTimeRecordCommandResponse = null;
try {
realTimeRecordCommandResponse = client.getAcsResponse(realTimeRecordCommandRequest);
} catch (ClientException e) {
e.printStackTrace();
}
System.out.println(new Gson().toJson(realTimeRecordCommandResponse));
setCommand("stop"): stops the recording.
To actively stop recording, you also need to wait for the Stream Stitching duration before the recording file is generated.
If you are recording a transcoded stream, you need to set <StreamName> in the format of
StreamName
plus_transcoding template ID
.
Stream splicing
Recording cycle configuration
Recording content merge and fetch
Recording management
References
When you encounter issues with live stream recording, see FAQ about live stream recording.
Using Java SDK, see Java SDK user guide.
For more information about recording callback features, see Live stream recording callback and On-demand recording callback.