Starts an RTC cloud recording task.
Operation description
Cloud recording is a billable feature. For more information, see Cloud recording pricing.
Endpoints
Call this operation from the following endpoints:
| Region | Region ID | Endpoint |
| China (Shanghai) | cn-shanghai | live.aliyuncs.com |
| Singapore | ap-southeast-1 | live.ap-southeast-1.aliyuncs.com |
| US (Virginia) | us-east-1 | live.us-east-1.aliyuncs.com |
QPS limit
The queries per second (QPS) limit for this operation is 50 per user. If you exceed this limit, your API calls are throttled, which may affect your business. Use this API responsibly.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
live:StartRtcCloudRecording |
create |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| AppId |
string |
Yes |
The ID of the app to which the channel to be recorded belongs. The app must belong to the Alibaba Cloud account that is used to call the API. |
********-7074-****-9ef5-85c19a4***** |
| ChannelId |
string |
Yes |
The ID of the channel to record. Ensure that users are in the channel when you call this API. Otherwise, the recording task fails to start. |
room1024 |
| SubscribeParams |
object |
Yes |
The subscription parameters. |
|
| SubscribeUserIdList |
array<object> |
Yes |
A list of user IDs to subscribe to. In single-stream recording mode, a separate recording is generated for each user ID. In stream mixing mode, the audio and video streams of all user IDs are mixed into a single stream. Note
|
|
|
object |
No |
The information about the subscribed user ID. |
||
| UserId |
string |
Yes |
The user ID to subscribe to. |
userA |
| StreamType |
integer |
No |
The media type of the stream for the user ID. Valid values:
|
0 |
| SourceType |
integer |
No |
The type of the video input stream for the user ID. This parameter is valid only when you subscribe to a stream that is not audio-only (StreamType is not 1). Valid values:
|
0 |
| RecordParams |
object |
Yes |
The recording parameters. |
|
| RecordMode |
integer |
Yes |
The recording mode. Valid values:
|
0 |
| StreamType |
integer |
No |
The media type of the output stream. Valid values:
|
0 |
| MaxFileDuration |
integer |
No |
The maximum duration of a recording file, in seconds. A recording file that exceeds the maximum duration is split. The value must be within the range of [180, 7200]. The maximum duration is 2 hours. If you do not specify this parameter, the default value of 2 hours is used. |
7200 |
| StorageParams |
object |
Yes |
The storage parameters. |
|
| StorageType |
integer |
Yes |
The storage method. Valid values:
|
1 |
| FileInfo |
array<object> |
No |
The information about file storage. This parameter is used to specify the format, storage location, and naming rules of recording files. This parameter is valid only when StorageType is set to OSS. Note
For each element in the array, a recording file is generated based on the specified configuration. If this parameter is not set, the configuration for the HLS format is used by default. If you set this parameter but do not include the configuration for the HLS format, the system automatically adds the default configuration for the HLS format. |
|
|
object |
No |
The storage configuration for different file formats. |
||
| Format |
string |
Yes |
The file format for storage. Valid values:
|
HLS |
| FileNamePattern |
string |
No |
The file naming pattern. You can combine the following variables in any order:
The default values are as follows:
Note
|
{AppId}_{ChannelId}_{StartTime}_{UserId} |
| SliceNamePattern |
string |
No |
The slice naming pattern. This parameter is valid only for the HLS format. This parameter is similar to FileNamePattern, but includes the Sequence variable.
The default values are as follows:
Note
|
{AppId}_{ChannelId}_{StartTime}_{Sequence} |
| FilePathPrefix |
array |
No |
The file storage path. The elements in the array correspond to directory levels. For example, if you set the value to ["dir1","dir2"], the xxx.m3u8 file is saved to dir1/dir2/TaskId/xxx.m3u8. If this parameter is empty, the file is saved to TaskId/xxx.m3u8.
|
|
|
string |
No |
The name of each directory level. |
dir1 |
|
| SliceDuration |
integer |
No |
The duration of a slice in seconds. This parameter is valid only for the HLS format. The value must be within the range of [10, 30]. The default value is 30. Use the default value unless you have specific requirements. |
30 |
| OSSParams |
object |
No |
The OSS storage configuration. This parameter is required when StorageType is set to OSS and is invalid when StorageType is set to VOD. |
|
| OSSEndpoint |
string |
Yes |
The name of the OSS endpoint. The region ID of the endpoint must be the same as the region of the selected endpoint. |
oss-cn-shanghai.aliyuncs.com |
| OSSBucket |
string |
Yes |
The name of the OSS bucket. The bucket must belong to the Alibaba Cloud account that is used to call the API. |
mytest-bucket |
| VodParams |
object |
No |
The VOD storage configuration. This parameter is required when StorageType is set to VOD and is invalid when StorageType is set to OSS. |
|
| StorageLocation |
string |
No |
The storage address that is included in the VOD console under Media Asset Management > Storage Management. Recording files are first saved to this address and then uploaded to VOD. |
mytest.oss-cn-shenzhen.aliyuncs.com |
| VodTranscodeGroupId |
string |
No |
The ID of the VOD transcoding template group. |
****8a914d3989e9825eb90530b2**** |
| AutoCompose |
integer |
No |
Specifies whether to enable automatic composition. Valid values:
|
0 |
| ComposeVodTranscodeGroupId |
string |
No |
The ID of the VOD transcoding template group that is used to transcode the new video composed in the VOD service. Note
|
****4c34112cfe68248f2f77759c**** |
| MixTranscodeParams |
object |
No |
The transcoding parameters. Do not specify this parameter for single-stream recording. This parameter is required for stream mixing. |
|
| FrameFillType |
integer |
No |
The frame filling type during a stream interruption. Valid values:
|
0 |
| AudioBitrate |
integer |
Yes |
The audio bitrate in kbit/s. The value must be within the range of [8, 500]. This parameter is required in stream mixing mode. |
300 |
| AudioChannels |
integer |
Yes |
The number of audio channels. Valid values:
This parameter is required in stream mixing mode. |
2 |
| AudioSampleRate |
integer |
Yes |
The audio sampling rate in Hz. Valid values:
This parameter is required in stream mixing mode. |
32000 |
| VideoCodec |
string |
No |
The video encoding format. Valid values:
|
H.264 |
| VideoBitrate |
integer |
No |
The video bitrate in kbit/s. The value must be within the range of [1, 10000]. In stream mixing mode, this parameter is required if the output recording includes video. In other cases, this parameter is invalid. |
5000 |
| VideoFramerate |
integer |
No |
The video frame rate in fps. The value must be within the range of [1, 60]. In stream mixing mode, this parameter is required if the output recording includes video. In other cases, this parameter is invalid. |
30 |
| VideoGop |
integer |
No |
The video GOP. An I-frame appears every VideoGop frames. The value must be within the range of [1, 60]. In stream mixing mode, this parameter is required if the output recording includes video. In other cases, this parameter is invalid. |
30 |
| VideoHeight |
integer |
No |
The video height in pixels. The value must be within the range of [0, 1920]. The default value is 0. |
480 |
| VideoWidth |
integer |
No |
The video width in pixels. The value must be within the range of [0, 1920]. The default value is 0. |
640 |
| MixLayoutParams |
object |
No |
The layout parameters. Do not specify this parameter for single-stream recording. This parameter is required in stream mixing mode if the output recording is not audio-only. |
|
| MixBackground |
object |
No |
The global background image for stream mixing. |
|
| RenderMode |
integer |
No |
The display mode for the output video. Valid values:
|
0 |
| Url |
string |
No |
The URL of the background image. The URL can be up to 2,048 characters in length. |
https://xxxx.com/photos/my-test-picture.png |
| UserPanes |
array<object> |
No |
The window layout information for subscribed users. Only users with specified layout information are included in the output video. This parameter is required in stream mixing mode for non-audio-only recordings. |
|
|
array<object> |
No |
The window configuration in the output video. |
||
| UserId |
string |
No |
The user ID that corresponds to this window.
|
userA |
| SourceType |
integer |
No |
The type of the video input stream for this user ID. This parameter is invalid if UserId is not specified. Valid values:
The combination of UserId and SourceType specified here must be included in SubscribeUserIdList. |
0 |
| Height |
string |
No |
The height of the pane. This value is a normalized percentage. The value must be within the range of [0, 1]. The default value is 0. |
0.5 |
| Width |
string |
No |
The width of the pane. This value is a normalized percentage. The value must be within the range of [0, 1]. The default value is 0. |
0.5 |
| X |
string |
No |
The X coordinate. This value is a normalized percentage. The value must be within the range of [0, 1]. The default value is 0. |
0 |
| Y |
string |
No |
The Y coordinate. This value is a normalized percentage. The value must be within the range of [0, 1]. The default value is 0. |
0 |
| ZOrder |
integer |
No |
The stacking order. Layer 0 is the bottom layer. Layer 1 is stacked on top of layer 0, and so on. The default value is 0. |
0 |
| SubBackground |
object |
No |
The background image of the sub-pane. This image is used when a user turns off their camera, does not publish a stream after joining the channel, or leaves the channel. The image fills the layout position. |
|
| RenderMode |
integer |
No |
The display mode for the sub-pane output. Valid values:
|
0 |
| Url |
string |
No |
The URL of the background image. The URL can be up to 2,048 characters in length. |
https://xxxx.com/photos/my-test-pane-picture.png |
| NotifyUrl |
string |
No |
The callback URL to receive task status messages. Messages are sent using POST requests in the JSON format. The URL can be up to 2,048 characters in length. For more information about callback messages, see On-cloud recording callback message. |
http://xxxx/test/mycallback |
| NotifyAuthKey |
string |
No |
The authentication key for callback messages. If this parameter is not specified, authentication is disabled. If this parameter is specified, the key must be 16 to 64 characters in length and can contain only letters and digits.
|
mytestkeymytestkey |
| NotifyFileUploadedFormat |
array |
No |
The formats for which callback messages are sent when the RecordFileUploaded event is triggered. |
|
|
string |
No |
The specific file formats for which to receive callbacks. Valid values (case-insensitive):
The VOD storage mode is not supported. For the OSS storage mode, the selected formats must be included in the file formats specified in StorageParams.FileInfo. |
MP4 |
|
| MaxIdleTime |
integer |
No |
The idle timeout period in seconds. If a task is idle for a period longer than the value of MaxIdleTime, the task automatically stops. The value must be within the range of [10, 14400]. The maximum period is 4 hours. The default value is 300 seconds.
|
600 |
-
For single-stream recording:
You can subscribe to both the camera and screen sharing streams of the same user ID. However, the FileNamePattern and SliceNamePattern parameters must include the SourceType variable to prevent recording files from being overwritten.
You cannot subscribe to only the video-only stream of a user ID. In single-stream mode, the value of UserInfo.StreamType cannot be 2.
-
In single-stream recording mode:
If RecordParams.StreamType is set to 1 (audio-only), you cannot subscribe to video-only streams in SubscribeParams (where StreamType is 2).
If RecordParams.StreamType is set to 2 (video-only), you cannot subscribe to audio-only streams in SubscribeParams (where StreamType is 1).
-
In stream mixing mode:
If RecordParams.StreamType is set to 1 (audio-only), the streams that you subscribe to in SubscribeParams cannot all be video-only streams (where StreamType is 2).
If RecordParams.StreamType is set to 2 (video-only), the streams that you subscribe to in SubscribeParams cannot all be audio-only streams (where StreamType is 1).
-
During recording, if the channel is closed, users must rejoin the channel and publish streams within the idle timeout period. Otherwise, the task stops automatically.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response content. |
||
| RequestId |
string |
The request ID. |
******58-5876-****-83CA-B56278****** |
| TaskId |
string |
The task ID. |
******73-8501-****-8ac1-72295a****** |
Examples
Success response
JSON format
{
"RequestId": "******58-5876-****-83CA-B56278******",
"TaskId": "******73-8501-****-8ac1-72295a******"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter.NotifyUrl | %s, please check the notifyUrl. | The parameter NotifyUrl format is invalid, please check. |
| 400 | InvalidParameter.StorageParams.FileInfo | %s, please check the fileInfo of storageParams. | The parameter FileInfo has invalid fields, please check. |
| 400 | InvalidParameter.StorageParams.OSSParams | %s, please check the ossParams of storageParams. | The parameter OSSParams has invalid fields, please check. |
| 400 | NotFound.OSSBucket | %s, please check the ossBucket of storageParams. | The parameter OSSBucket does not exist. |
| 400 | InvalidParameter.SubscribeParams.SubscribeUserIdList | %s, please check the subscribeUserIdList of subscribeParams. | The parameter SubscribeUserIdList is invalid, please check. |
| 400 | InvalidParameter.MixLayoutParams.UserPanes | %s, please check the userPanes of mixLayoutParams. | The parameter UserPanes has invalid fields, please check. |
| 400 | InvalidParameter.MixTranscodeParams | %s, please check the transcodeParams. | The parameter MixTranscodeParams has invalid fields, please check. |
| 400 | MissingParameter | %s. | Missing parameter |
| 403 | InvalidParameter.UserId | %s, please check the UserId. | UserId is invalid, please check. |
| 404 | InvalidParameter.ChannelId | %s, please check the channelId. | |
| 404 | InvalidParameter.AppId | %s, please check the appId. | The parameter AppId is invalid. Check it. |
| 405 | InvalidParameter.StorageParams.VodParams | %s, please check the vodParams of storageParams. | |
| 405 | InvalidParameter.NotifyAuthKey | %s, please check the notifyAuthKey. | |
| 405 | InvalidParameter.MaxIdleTime | %s, please check the maxIdleTime. | |
| 405 | InvalidParameter.RecordParams | %s, please check the recordParams. | |
| 405 | InvalidParameter.StorageParams.StorageType | %s, please check the storageType of storageParams. | The parameter StorageType is invalid, please check. |
| 405 | InvalidParameter.NotifyFileUploadedFormat | %s, please check the notifyFileUploadedFormat. | The parameter NotifyFileUploadedFormat is invalid, please check. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.