StartRtcCloudRecording

Updated at:

Starts an RTC cloud recording task.

Operation description

Cloud recording is a paid feature. For billing details, refer to Cloud recording billing.

Note
  • After you start a recording task, fees are still incurred in the idle state (when no stream is ingested). Therefore, call StopRtcCloudRecording promptly when the recording ends, or reduce MaxIdleTime as needed.

  • The default number of concurrent tasks supported per account varies by region:

    • Shanghai: 500 concurrent tasks

    • Singapore: 200 concurrent tasks

    • US East: 500 concurrent tasks

  • To increase the quota, contact your Alibaba Cloud account manager or submit a ticket. For more information about how to submit a ticket, refer to Contact us.

Important This operation is asynchronous. A successful call does not indicate that the task is recording. Set the NotifyUrl request parameter to receive task status notifications.

Service registration endpoints

The active service registration endpoints for this operation include:

Region nameRegion IDPublic endpoint
Shanghaicn-shanghailive.aliyuncs.com
Singaporeap-southeast-1live.ap-southeast-1.aliyuncs.com
US (Virginia)us-east-1live.us-east-1.aliyuncs.com

QPS limits

The QPS limit per user is 50 calls per second. If the limit is exceeded, API calls are throttled, which may affect your services. Call the operation at a reasonable frequency.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

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 application to which the channel to be recorded belongs. The application must belong to the Alibaba Cloud account of the current caller.

********-7074-****-9ef5-85c19a4*****

ChannelId

string

Yes

The ID of the channel to be recorded. Make sure that users are present in the channel when you call this operation. Otherwise, the recording task fails to be created.

room1024

SubscribeParams

object

Yes

The subscription parameters.

SubscribeUserIdList

array<object>

Yes

The list of subscribed user IDs. In single-stream recording mode, each user ID is recorded separately. In stream mixing recording mode, the audio and video of all user IDs are mixed into a single audio and video stream.

Note
  • The array cannot be empty and supports a maximum of 17 elements.

object

No

The information about the subscribed user ID.

UserId

string

Yes

The subscribed user ID.

userA

StreamType

integer

No

The media type of the subscribed user ID. Valid values:

  • 0: original stream, which includes both audio and video (default).

  • 1: audio-only stream.

  • 2: video-only stream (valid only in stream mixing recording mode).

Valid values:

  • 0 :

    Original stream, which includes both audio and video.

  • 1 :

    Audio-only stream.

  • 2 :

    Video-only stream.

0

SourceType

integer

No

The video input stream type of the user ID. This parameter is valid only when a non-audio-only stream is subscribed to (StreamType != 1). Valid values:

  • 0: camera (default).

  • 1: screen sharing.

Valid values:

  • 0 :

    Camera.

  • 1 :

    Screen sharing.

0

RecordParams

object

Yes

The recording parameters.

RecordMode

integer

Yes

The recording mode. Valid values:

  • 0: single-stream recording mode. A separate recording file is generated for each subscribed user ID.

  • 1: stream mixing recording mode. The streams of the subscribed user IDs are mixed and transcoded, and only one set of recording files is generated.

Valid values:

  • 0 :

    Single-stream recording mode. A separate recording file is generated for each subscribed user ID.

  • 1 :

    Stream mixing recording mode. The streams of the subscribed user IDs are mixed and transcoded, and only one set of recording files is generated.

0

StreamType

integer

No

The media type of the recorded output stream. Valid values:

  • 0: original stream, which includes both audio and video (default).

  • 1: audio-only stream.

  • 2: video-only stream.

Valid values:

  • 0 :

    Original stream, which includes both audio and video.

  • 1 :

    Audio-only stream.

  • 2 :

    Video-only stream.

0

MaxFileDuration

integer

No

The maximum duration of a recording file, in seconds. Recording files that exceed this duration are split. Valid values: 180 to 7200, which means a maximum of 2 hours. If you do not specify this parameter, the default value is 7200 (2 hours).

7200

StorageParams

object

Yes

The storage parameters.

StorageType

integer

Yes

The storage method. Valid values:

  • 0: VOD

  • 1: OSS

Valid values:

  • 0 :

    VOD

  • 1 :

    OSS

1

FileInfo

array<object>

No

The file storage information, which is used to specify the format, storage location, and naming convention of the recording files. This parameter is valid only when StorageType is set to OSS.

Note

A recording file is generated for each element in the array based on the corresponding configuration. If no format is specified, the HLS format is included by default.

object

No

The storage configuration for different file formats.

Format

string

Yes

The file storage format. Valid values:

  • HLS

  • MP4

  • MP3

Valid values:

  • MP4 :

    MP4 format.

  • MP3 :

    MP3 format.

  • HLS :

    HLS format.

HLS

FileNamePattern

string

No

The file naming convention. You can select and combine the following variables in any order:

  • AppId

  • ChannelId

  • UserId (required in single-stream mode; invalid in stream mixing mode. If selected, the {UserId} string is retained)

  • RecordMode

    • 0 corresponds to Single.

    • 1 corresponds to Mix.

  • SourceType

    • In single-stream mode, when the stream type is video-only, this configuration takes effect. SourceType can be set to:
      • 0 corresponds to C (Camera) video stream.

      • 1 corresponds to S (Screen) screen sharing video stream.

    • In single-stream mode, when the stream type is audio-only, SourceType is automatically set to A (Audio) to indicate that the recording is an audio-only stream.

    • In single-stream mode, when the stream type is original stream, this configuration takes effect. SourceType can be set to:
      • 0 corresponds to OC (Original Camera) original stream.

      • 1 corresponds to OS (Original Screen) screen sharing original stream.

    • In other scenarios, the SourceType configuration is invalid. If you manually configure SourceType, the system retains the {SourceType} placeholder string.

  • StreamType (uses the StreamType parameter under RecordParams)

    • 0 corresponds to AV (Audio Video) audio and video stream.

    • 1 corresponds to A (Audio) audio stream.

    • 2 corresponds to V (Video) video stream.

  • StartTime: the time when the recording starts. The time is in the UTC+8 time zone, in a format similar to 2025-03-25-11:27:28. (Required if the default value is not used)

Default values:

  • Single-stream recording mode
    • {AppId}_{ChannelId}_{UserId}_{StartTime}

    • If different StreamTypes or SourceTypes of the same UserId are subscribed to at the same time, the default value is {AppId}_{ChannelId}_{UserId}_{SourceType}_{StartTime}.

  • Stream mixing recording mode
    • {AppId}_{ChannelId}_{StartTime}

Note
  • The string can only consist of the preceding variables. Variable names must be enclosed in braces ({}), separated by an underscore (_), and each variable can appear at most once in the string.

  • If the file is named xxx, it is ultimately saved in a format similar to TaskId/xxx.m3u8, where TaskId is the task ID generated when the cloud recording task is started and is automatically added to the storage path.

{AppId}_{ChannelId}_{StartTime}_{UserId}

SliceNamePattern

string

No

The segment naming convention, valid only in HLS format. It is similar to FileNamePattern, except that the Sequence variable is also available:

  • AppId

  • ChannelId

  • UserId (required in single-stream mode; invalid in stream mixing mode. If selected, the {UserId} string is retained)

  • RecordMode

    • 0 corresponds to Single.

    • 1 corresponds to Mix.

  • SourceType

    • In single-stream mode, when the stream type is video-only, this parameter takes effect. SourceType can be set to:
      • 0 corresponds to C (Camera) video stream.

      • 1 corresponds to S (Screen) screen sharing stream.

    • In single-stream mode, when the stream type is audio-only, SourceType is automatically set to A (Audio) to indicate that the recording is an audio-only stream.

    • In single-stream mode, when the stream type is original stream, this configuration takes effect. SourceType can be set to:
      • 0 corresponds to OC (Original Camera) original stream.

      • 1 corresponds to OS (Original Screen) screen sharing original stream.

    • In other scenarios, the SourceType configuration is invalid. If you manually configure this parameter, the system retains the {SourceType} placeholder string.

  • StreamType (uses the StreamType parameter under RecordParams)

    • 0 corresponds to AV (Audio Video), which includes audio and video streams.

    • 1 corresponds to A (Audio) audio stream.

    • 2 corresponds to V (Video) video stream.

  • StartTime: the time when the recording starts. The time is in the UTC+8 time zone, in a format similar to 2025-03-25-11:27:28. (Required if the default value is not used).

  • Sequence: in HLS format, the .ts file name includes Sequence. This variable is invalid in other formats. (Required if the default value is not used).

Default values:

  • Single-stream recording mode
    • {AppId}_{ChannelId}_{UserId}_{StartTime}_{Sequence}

    • If different StreamTypes or SourceTypes of the same UserId are subscribed to at the same time, the default value is {AppId}_{ChannelId}_{UserId}_{SourceType}_{StartTime}_{Sequence}.

  • Stream mixing recording mode
    • {AppId}_{ChannelId}_{StartTime}_{Sequence}

Note
  • The string can only consist of the preceding variables. Variable names must be enclosed in braces ({}), separated by an underscore (_), and each variable can appear at most once in the string.

  • If the segment is named xxx, it is ultimately saved in a format similar to TaskId/xxx.ts, where TaskId is the task ID generated when the cloud recording task is started and is automatically added to the storage path.

{AppId}_{ChannelId}_{StartTime}_{Sequence}

FilePathPrefix

array

No

The file storage path. Elements in the array correspond to each directory level. For example, if the parameter value is ["dir1","dir2"], the xxx.m3u8 file is saved as dir1/dir2/TaskId/xxx.m3u8. If this parameter is empty, the preceding example is saved directly as TaskId/xxx.m3u8.

  • The TaskId of the task is automatically appended to the end of the path to prevent recording files of different tasks from being mixed.

  • If FilePathPrefix is set, each element in the array can only contain English letters (a-zA-Z), digits (0-9), hyphens (-), and underscores (_), and cannot be an empty string.

  • After the paths at all levels in the array are concatenated, the total length cannot exceed 128 characters (including the connecting '/', but excluding the automatically filled TaskId). For example, if the parameter value is ["dir1","dir2"], the concatenated path is "dir1/dir2/". That is, the sum of the total number of characters of all elements in the array and the length of the array (corresponding to the "/" after each level of path) must not exceed 128.

  • The number of elements in the array cannot exceed 5, which means a maximum of 5 levels of custom paths.

string

No

The name of each directory level.

dir1

SliceDuration

integer

No

The segment length, in seconds. This parameter is valid only in HLS format. Valid values: 10 to 30. Default value: 30.

If you have no special requirements, use the default value.

30

OSSParams

object

No

The OSS storage configuration. This parameter is required when the storage method is OSS, and is invalid when the storage method is VOD.

OSSEndpoint

string

Yes

The endpoint of the OSS bucket. The corresponding region ID must be consistent with the selected service registration endpoint.

oss-cn-shanghai.aliyuncs.com

OSSBucket

string

Yes

The name of the OSS bucket. The bucket must belong to the Alibaba Cloud account of the current caller.

mytest-bucket

VodParams

object

No

The VOD storage configuration. This parameter is required when the storage method is VOD, and is invalid when the storage method is OSS.

Note
  • Recording to VOD is not supported in the US (Virginia) region.

StorageLocation

string

No

The storage address included in the video-on-demand console > Media Asset Management > Storage Management. Recording files are first saved here and then uploaded to video-on-demand.

Note
  • This parameter is required when StorageType is set to 0 (video-on-demand pattern).

  • Make sure that the area of the storage address is consistent with the selected service registration endpoint.

mytest.oss-cn-shenzhen.aliyuncs.com

VodTranscodeGroupId

string

No

The ID of the video-on-demand transcoding template group.

Note
  • This parameter is required when StorageType is set to 0 (video-on-demand pattern).

  • Make sure that the area of the transcoding template group ID is consistent with the selected service registration endpoint.

****8a914d3989e9825eb90530b2****

AutoCompose

integer

No

Specifies whether to enable automatic merging. Valid values:

  • 0: disable automatic merging (default).

  • 1: enable automatic merging. When enabled, the ComposeVodTranscodeGroupId parameter must be set.

Valid values:

  • 0 :

    Disable automatic merging.

  • 1 :

    Enable automatic merging. When enabled, the ComposeVodTranscodeGroupId parameter must be set.

0

ComposeVodTranscodeGroupId

string

No

The ID of the video-on-demand transcoding template group used to transcode the newly synthesized video in the video-on-demand service.

Note
  • This parameter is required only when AutoCompose (whether to enable automatic merging) is set to 1.

  • If there is only one media resource file when the recording ends, automatic merging is not triggered even if it is enabled.

  • For FAQ about automatic synthesis and transcoding, refer to FAQ about live-to-video-on-demand.

  • For billing details of video-on-demand transcoding, refer to Media asset transcoding billing.

****4c34112cfe68248f2f77759c****

MixTranscodeParams

object

No

The transcoding parameters. Do not specify this parameter in single-stream recording mode. This parameter is required in stream mixing recording mode.

FrameFillType

integer

No

The frame filling type when the stream is interrupted. Valid values:

  • 0: fill with the last frame (default).

Valid values:

  • 0 :

    Fill with the last frame.

0

AudioBitrate

integer

Yes

The audio bitrate, in Kbit/s. Valid values: 8 to 500. This parameter is required in stream mixing mode.

300

AudioChannels

integer

Yes

The number of audio channels. Valid values:

  • 1: mono.

  • 2: stereo.

This parameter is required in stream mixing mode.

Valid values:

  • 1 :

    Mono.

  • 2 :

    Stereo.

2

AudioSampleRate

integer

Yes

The audio sampling rate, in Hz. Valid values:

  • 8000

  • 16000

  • 32000

  • 44100

  • 48000

This parameter is required in stream mixing mode.

Valid values:

  • 8000 :

    8000HZ

  • 16000 :

    16000HZ

  • 32000 :

    32000HZ

  • 44100 :

    44100HZ

  • 48000 :

    48000HZ

32000

VideoCodec

string

No

The video codec. Valid values:

  • H.264 (default)

  • H.265

Valid values:

  • H.264 :

    H.264

  • H.265 :

    H.265

H.264

VideoBitrate

integer

No

The video bitrate, in Kbit/s. Valid values: 1 to 10000. In stream mixing mode, this parameter is required if you expect the recording output to include video. It is invalid in other cases.

5000

VideoFramerate

integer

No

The video frame rate, in fps. Valid values: 1 to 60. In stream mixing mode, this parameter is required if you expect the recording output to include video. It is invalid in other cases.

30

VideoGop

integer

No

The video GOP. An I-frame exists every VideoGop frames. Valid values: 1 to 60. In stream mixing mode, this parameter is required if you expect the recording output to include video. It is invalid in other cases.

30

VideoHeight

integer

No

The video height, in pixels. Valid values: 0 to 1920. Default value: 0.

480

VideoWidth

integer

No

The video width, in pixels. Valid values: 0 to 1920. Default value: 0.

640

MixLayoutParams

object

No

The layout parameters. Do not specify this parameter in single-stream recording mode. This parameter is required in stream mixing recording mode if you expect to record a non-audio-only file.

MixBackground

object

No

The global background image for stream mixing.

RenderMode

integer

No

The display mode when the video is output. Valid values:

  • 0: crop (default).

  • 1: scale and display a black background.

Valid values:

  • 0 :

    Crop.

  • 1 :

    Scale and display a black background.

0

Url

string

No

The URL of the background image. The maximum length is 2,048 characters.

https://xxxx.com/photos/my-test-picture.png

UserPanes

array<object>

No

Specifies the window layout information for subscribed users. Only users whose UserIds are configured with layout information are displayed in the video. This parameter is required when stream mixing is enabled and the recording is not a pure audio file.

array<object>

No

The window configuration in the video.

UserId

string

No

The UserId corresponding to this window.

  • If UserId is not specified, the windows are filled in the order in which subscribed users join the channel.

  • The combination of UserId and SourceType specified here must be included in SubscribeUserIdList.

  • Subscribed pure audio streams cannot be added to the layout.

userA

SourceType

integer

No

The video input stream type of the UserId. If UserId is not specified, the SourceType setting here is invalid. Valid values:

  • 0: Camera. (Default)

  • 1: Screen sharing.

The combination of UserId and SourceType specified here must be included in SubscribeUserIdList.

Valid values:

  • 0 :

    Camera.

  • 1 :

    Screen sharing.

0

Height

string

No

The height of the pane, as a normalized percentage. The value must be in the range of [0,1]. Default value: 0.

0.5

Width

string

No

The width of the pane, as a normalized percentage. The value must be in the range of [0,1]. Default value: 0.

0.5

X

string

No

The X coordinate, as a normalized percentage. The value must be in the range of [0,1]. Default value: 0.

0

Y

string

No

The Y coordinate, as a normalized percentage. The value must be in the range of [0,1]. Default value: 0.

0

ZOrder

integer

No

The stacking order. 0 indicates the bottom layer, 1 indicates the layer above 0, and so on. Default value: 0.

0

SubBackground

object

No

The background image for the sub-picture. If a user turns off the camera, does not publish a stream after joining the channel, or leaves the channel midway, the corresponding image is displayed in the layout position.

RenderMode

integer

No

The display mode when the sub-picture is output. Valid values:

  • 0: Crop. (Default)

  • 1: Scale and display with a black background.

Valid values:

  • 0 :

    Crop.

  • 1 :

    Scale and display a black background.

0

Url

string

No

The URL of the background image. The maximum length is 2,048 characters.

https://xxxx.com/photos/my-test-pane-picture.png

NotifyUrl

string

No

The URL for receiving callback messages. Task status messages are pushed to this URL in JSON format by using the POST method. The maximum length is 2,048 characters.

For more information about callback messages, refer to the documentation.

Note
  • The callback URL must be a valid public URL and resolvable by DNS. Otherwise, you will not receive callback messages.

http://xxxx/test/mycallback

NotifyAuthKey

string

No

The authentication key for callback messages. By default, this parameter is left empty, which means no authentication is performed. If specified, the length must be 16 to 64 characters and can contain only uppercase and lowercase letters and digits.

  • If NotifyUrl is not specified, NotifyAuthKey is invalid.

  • If a valid NotifyAuthKey is specified, authentication information is included in the callback messages.

mytestkeymytestkey

NotifyFileUploadedFormat

array

No

The specified formats. When a recording file generation event (RecordFileUploaded) is triggered, a callback message is sent.

string

No

The specific file formats for which you want to receive callbacks. Valid values (case-insensitive):

  • SLICE

  • HLS

  • MP4

  • MP3

VOD storage mode is not supported. For OSS storage mode, the selected formats must be included in the file formats of StorageParams.FileInfo.

MP4

MaxIdleTime

integer

No

The idle timeout period. If the task remains idle for a duration that exceeds MaxIdleTime, the task is automatically stopped. Unit: seconds. Valid values: 10 to 14400, which is up to 4 hours. Default value: 300.

  • In stream mixing recording mode, the task is considered idle when all subscribed user streams stop publishing.

  • In single-stream recording mode, subscribed streams are independent of each other. The task is considered idle when any stream stops publishing. After MaxIdleTime is reached, the recording of this stream is stopped. When all subscribed streams time out due to idleness, the entire cloud recording task is stopped.

600

  • For single-stream recording mode:

    • You can subscribe to both the camera and screen sharing of the same UserId at the same time. However, the FileNamePattern and SliceNamePattern parameters must contain the SourceType variable to prevent recording files from overwriting each other.

    • Subscribing only to the pure video stream of a specific UserId is not supported. That is, in single-stream mode, the value of UserInfo.StreamType cannot be set to 2.

  • In single-stream recording mode:

    • If RecordParams.StreamType is set to pure audio stream (value 1), SubscribeParams cannot be set to subscribe to pure video (value 2).

    • If RecordParams.StreamType is set to pure video stream (value 2), SubscribeParams cannot be set to subscribe to pure audio (value 1).

  • In stream mixing recording mode:

    • If RecordParams.StreamType is set to pure audio stream (value 1), not all UserIds in SubscribeParams can be set to subscribe only to pure video (value 2).

    • If RecordParams.StreamType is set to pure video stream (value 2), not all UserIds in SubscribeParams can be set to subscribe only to pure audio (value 1).

  • During recording, if the channel is closed midway, you must rejoin the channel and publish a stream within the idle timeout period. Otherwise, the task is automatically stopped.

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.
403 QuotaExceed.RunningTask The number of active cloud recording tasks has reached the limit. The number of active cloud recording tasks has reached the limit.
404 InvalidParameter.ChannelId %s, please check the channelId. The parameter ChannelId is invalid, please check.
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. The parameter VodParams has invalid fields, please check.
405 InvalidParameter.NotifyAuthKey %s, please check the notifyAuthKey. The parameter NotifyAuthKey format is invalid, please check.
405 InvalidParameter.MaxIdleTime %s, please check the maxIdleTime. The parameter MaxIdleTime is invalid, please check.
405 InvalidParameter.RecordParams %s, please check the recordParams. The parameter RecordParams has invalid fields, please check.
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.