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 audio individual non-transcoding recording

Get a resource ID

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

acquire request over HTTPS

  • Request URL:


    _1
    https://api.agora.io/v1/apps/<your-appid>/cloud_recording/acquire

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

  • Authorization: Basic authorization. For more information, see Authenticate REST calls.

  • 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

start request over HTTPS

  • Request URL:


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

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

  • Authorization: Basic authorization. For more information, see Authenticate REST calls.

  • Request body:


    _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
    }

    info

    To configure the vendor and region parameters, see Third-party cloud storage regions.

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, call the acquire method for a new resource ID.

stop request over HTTPS

  • The request URL is:


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

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

  • Authorization: Basic authorization. For more information, see Authenticate REST calls.

  • Request body:


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

Recorded files

For file naming rules, 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.