Skip to main content

Individual audio non-transcoding recording

Overview

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.

If you need to get the mixed audio recording files of all users in the channel, you can enable the Postpone Audio Mixing function when starting the individual audio non-transcoding recording.

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
}

Implement an Postpone Audio Mixing

If you want to get the mixed audio recording files of all users in the channel, you can enable the Postpone Audio Mixing function when starting an individual audio non-transcoding recording. After you enable this function, the recording service merges and transcodes the recording files of all user IDs in the specified channel within 24 hours after the recording ends to generate an MP3/M4A/AAC file, and then uploads the recording file to the third-party cloud storage you specify.

Enable Postpone Audio Mixing

To enable individual recording mode, set mode to individual when calling start.

Configure the following parameters in clientRequest for Postpone Audio Mixing:

ParameterDescriptionNote
tokenString. The dynamic key used for the channel to record.Required if the channel uses a token.
appsCollectionJSON. Configures how the application services are combined and applied.Required.
appsCollection.combinationPolicyString. The combination method of various Cloud Recording applications, set to postpone_transcoding for Postpone Audio Mixing。Required.
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.
transcodeOptionsJSON. Configures how the Cloud Recording service transcode the recording files. It is applicable to Postpone Audio Mixing.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


_45
{
_45
"uid": "527841",
_45
"cname": "httpClient463224",
_45
"clientRequest": {
_45
"token": "<token if any>",
_45
"appsCollection": {
_45
"combinationPolicy": "postpone_transcoding"
_45
},
_45
"recordingConfig": {
_45
"maxIdleTime": 30,
_45
"streamTypes": 0,
_45
"streamMode": "original",
_45
"channelType": 0,
_45
"subscribeAudioUids": [
_45
"123",
_45
"456"
_45
],
_45
"subscribeUidGroup": 0
_45
},
_45
"transcodeOptions": {
_45
"container": {
_45
"format": "m4a"
_45
},
_45
"transConfig": {
_45
"transMode": "audioMix"
_45
},
_45
"audio": {
_45
"sampleRate": "48000",
_45
"bitrate": "48000",
_45
"channels": "2"
_45
}
_45
},
_45
"storageConfig": {
_45
"accessKey": "xxxxx",
_45
"region": 3,
_45
"bucket": "xxxxx",
_45
"secretKey": "xxxxx",
_45
"vendor": 2,
_45
"fileNamePrefix": [
_45
"directory1",
_45
"directory2"
_45
]
_45
}
_45
}
_45
}

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.

If you enable Postpone Audio Mixing, you can also get the MP3/M4A/AAC file of all user IDs mixed in the channel within 24 hours after the Audio Individual non-transcoding Recording ends.

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