Skip to main content

Individual recording

This guide includes the key steps in using the Cloud Recording RESTful API to make an individual recording. For more information, see Get started.

Overview

Agora Cloud Recording supports three recording modes:

  • Individual recording

  • Composite recording

  • Web page recording

In individual recording mode, the audio and video of each user ID in a channel are recorded in separate files.

Agora recommends that you use the standard mode when you start individual recording, and get audio and video files that can be played directly for each user IDs after the recording stops. For details, see Start recording.

For example, if a channel has two users and you choose to record both audio and video, the files generated for standard mode of individual recording is shown in the following diagram:

Image

Implementation

Get a resource ID

Before recording, call the acquire method to apply for a resource ID.

An HTTP request example of acquire

  • Request URL:

_1
https://api.agora.io/v1/apps/<yourappid>/cloud_recording/acquire


_8
{
_8
"cname": "https://xxxxx",
_8
"uid": "527841",
_8
"clientRequest": {
_8
"resourceExpiredHour": 24,
_8
"scene": 0
_8
}
_8
}

Start recording

To enable individual recording mode, set mode to individual when calling start. Use recordingConfig to configure individual recording, and use storageConfig to configure your third-party cloud storage.

Agora recommends that you use the standard mode when you start recording, that is, set the streamMode field in the recordingConfig parameterto standard to generate combined audio and video files that can be played directly.

In individual recording mode, you can configure the following parameters in clientRequest:

ParameterDescriptionNote
tokenString. The dynamic key used for the channel to record.JSON. Required if the channel uses a token
recordingConfigJSON. Configures stream subscription, transcoding, and the profile of the output audio and video.Required
recordingConfig.streamModeString. The output mode of the media stream in individual recording mode.Required
recordingFileConfigJSON. Configures the recorded files.Optional
storageConfigJSON. Configures the third-party cloud storage.Required

An HTTP request example of start

  • Request URL:

_1
https://api.agora.io/v1/apps/<yourappid>/cloud_recording/resourceid/<resourceid>/mode/individual/start

Real-time recording for standard mode


_33
{
_33
"uid": "527841",
_33
"cname": "httpClient463224",
_33
"clientRequest": {
_33
"token": "<token if any>",
_33
"recordingConfig": {
_33
"maxIdleTime": 30,
_33
"streamTypes": 2,
_33
"channelType": 0,
_33
"videoStreamType": 0,
_33
"subscribeVideoUids": [
_33
"123",
_33
"456"
_33
],
_33
"subscribeAudioUids": [
_33
"123",
_33
"456"
_33
],
_33
"subscribeUidGroup": 0
_33
},
_33
"storageConfig": {
_33
"accessKey": "xxxxxxf",
_33
"region": 3,
_33
"bucket": "xxxxx",
_33
"secretKey": "xxxxx",
_33
"vendor": 2,
_33
"fileNamePrefix": [
_33
"directory1",
_33
"directory2"
_33
]
_33
}
_33
}
_33
}

Stop recording

When a recording finishes, call stop to leave the channel and stop recording. To use Agora Cloud Recording again, you need to call the acquire method for a new resource ID.

An HTTP request example of stop

  • The request URL is:

_1
http://api.agora.io/v1/apps/<yourappid>/cloud_recording/resourceid/<resourceid>/sid/<sid>/mode/individual/stop


_5
{
_5
"cname": "httpClient463224",
_5
"uid": "527841",
_5
"clientRequest": {}
_5
}

Recorded files

In individual recording mode, the audio and video profiles of the recorded file are as follows:

  • Audio profile: The sample rate is 48 kHz, and the bitrate and number of audio channels are the same as those of the original audio stream.

  • Video profile: The video profile of the recorded file is the same as that of the original video stream.

The recorded files vary according to the recorded content. See the table below.

Recorded contentSettingsRecorded files
Audio onlySet streamTypes to 0One M3U8 file and several TS files for each user ID. The TS files store the audio.
Video onlySet streamTypes to 1One M3U8 file and several TS/WebM files for each user ID. The TS/WebM files store the video.
Audio and video, and standard modeSet streamTypes to 2 and streamMode to standardOne M3U8 audio index file, one M3U8 video index file, a combined M3U8 audio and video index file, multiple TS audio slice files and multiple TS video slice files are generated per user ID. If VP9 encoding is used on the web side, a combined MPD audio and video index file and multiple WebM video slice files are generated per user ID.

For detailed information about the naming conventions of the recorded files, see Manage Recorded Files.

Considerations

  • Use standard mode to record (set streamMode to standard), if you switch the native side to the web side (or vice versa) during the recording process, two combined audio and video index files in M3U8 format and MPD format are generated after recording, and the whole recording process cannot be played continuously.

  • The recording effects of Web SDK 4.x after disabling the video track are shown below:

PublisherWays to disable the video trackRecording effects
Web SDK 4.xCall setEnabled methodDisplays the last frame on the user screen in this slice and does not continue to generate video slices.
vundefined