Skip to main content

Individual audio non-transcoding recording

When recording audio only (streamTypes is 0) in individual recording mode, you can choose whether to use transcoding recording or non-transcoding recording through simple parameter settings. The differences between the two are as follows:

Individual Audio RecordingIndividual Audio Non-transcoding Recording
Whether to transcode when encoding audioYes.No.
Audio profileThe sample rate, number of audio channels, and bitrate are fixed at 48 kHz, mono, and 48 Kbps, respectively.The sample rate, number of audio channels, and bitrate are determined by the AudioProfile configuration of the streaming sender.
Audio codecLC-AAC.Determined by the AudioProfile configuration set by the streaming sender.
Recorded filesOne M3U8 file and several TS files are generated per user ID.The same as Individual transcoding recording. However, when the user calls mute, disable, or leaveChannel, the audio recording is stopped immediately, and there is no recorded data for silenced audio frames.
Player compatibilityUse a player that supports the HLS protocol to play recorded files.The audio codec format is determined by the AudioProfile configured by the streaming sender, and player compatibility varies by audio codec.

Implement an Audio Individual non-transcoding Recording

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

  • Content-type: application/json;charset=utf-8

  • Authorization: Basic authorization. For more information, see How to pass the basic HTTP authentication.

  • Request body:


_8
{
_8
"cname": "httpClient463224",
_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.

Configure the following parameters in clientRequest for Audio Individual non-transcoding Recording:

ParameterDescriptionNote
tokenString. The dynamic key used for the channel to record.Required if the channel uses a token.
recordingConfigJSON. Configures stream subscription, transcoding, and the profile of the output audio and video.Required.
recordingConfig.streamTypesNumber. The type of the media stream to subscribe to. Set this to 0 for Audio Individual non-transcoding Recording.Required.
recordingConfig.streamModeString. The output mode of the media stream in individual mode. Set this to original for Audio Individual non-transcoding Recording.Required.
storageConfigJSON. Configures the third-party cloud storage.Required.

An HTTP request example of start

  • Request URL:

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


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

When the user who publishes the stream mutes or leaves the channel, the recording service immediately slices the audio file and stops recording.

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


_8
{
_8
"cname": "httpClient463224",
_8
"uid": "527841",
_8
"clientRequest":{
_8
"resourceExpiredHour": 24,
_8
"scene": 0
_8
}
_8
}

Recorded files

For the naming rules of recorded files, see Manage Recording Files. You can play M3U8 audio files, or you can use the Agora Format Converter Script to merge and convert all TS files of the specified user ID into one MP3/M4A/AAC audio file for playback. See Merge Audio and Video Files after an Individual Recording for details.

Callback events

You can subscribe to the related callback events of the cloud recording service (serviceType is 0) before you start an individual audio non-transcoding recording. For details, see Callback Events.

vundefined