This guide includes the key steps in using the Cloud Recording RESTful API to make a composite recording. For more information, see Agora Cloud Recording RESTful API Quickstart.
Agora Cloud Recording supports three recording modes:
In composite recording mode, the audio and video of multiple UIDs in a channel are recorded in a single file.
For example, if a channel has two users and you choose to record both audio and video, Agora Cloud Recording generates one M3U8 file and several TS files in total, as shown in the following diagram:
After merging the files using the Audio & Video File Merging script, the two users' audio and video are stored together in one MP4 file.
Before recording, call the acquire
method to apply for a resource ID.
acquire
Request URL:
https://api.agora.io/v1/apps/<yourappid>/cloud_recording/acquire
Content-type
: application/json;charset=utf-8
Authorization
: Basic authorization. For more information, see How to pass the basic HTTP authentication.
Request body:
{
"cname": "httpClient463224",
"uid": "527841",
"clientRequest":{
"resourceExpiredHour": 24,
"scene": 0
}
}
To enable composite recording mode, set mode
to mix
when calling start
. Use recordingConfig
to configure composite recording, and use storageConfig
to configure your third-party cloud storage.
In composite recording mode, you can configure the following parameters in clientRequest
:
Parameter | Description | Note |
---|---|---|
token |
The dynamic key used for the channel to record. | Required if the channel uses a token |
recordingConfig |
Configures stream subscription, transcoding, and the profile of the output audio and video. | Required |
recordingFileConfig |
Configures the recorded files. | Optional |
storageConfig |
Configures the third-party cloud storage. | Required |
start
https://api.agora.io/v1/apps/<yourappid>/cloud_recording/resourceid/<resourceid>/mode/mix/start
Content-type
: application/json;charset=utf-8
Authorization
: Basic authorization. For more information, see How to pass the basic HTTP authentication.{
"uid": "527841",
"cname": "httpClient463224",
"clientRequest": {
"token": "<token if any>",
"recordingConfig": {
"maxIdleTime": 30,
"streamTypes": 2,
"audioProfile": 1,
"channelType": 0,
"videoStreamType": 1,
"transcodingConfig": {
"height": 640,
"width": 360,
"bitrate": 500,
"fps": 15,
"mixedVideoLayout": 1,
"backgroundColor": "#FF0000"
},
"subscribeVideoUids": ["123","456"],
"subscribeAudioUids": ["123","456"],
"subscribeUidGroup": 0
},
"storageConfig": {
"accessKey": "xxxxxxf",
"region": 3,
"bucket": "xxxxx",
"secretKey": "xxxxx",
"vendor": 2,
"fileNamePrefix": ["directory1","directory2"]
}
}
}
The recorded files vary according to the recorded content. See the table below:
Recorded content | Settings | Recorded files |
---|---|---|
Audio only | Set streamTypes as 0 |
One M3U8 file and several TS files. The TS files store the audio. |
Video only | Set streamTypes as 1 |
One M3U8 file and several TS files. The TS files store the video. |
Audio and video | Set streamTypes as 2 (default) |
Two M3U8 files and several TS files. The TS files store the audio and video. |
For detailed information about the naming conventions of the recorded files, see Manage Recorded Files.