Record Audio by the Client
Update time: 2025/06/11 16:45:39
NERTC SDK supports recording by client or server during an audio and video call. For recording by the client, audio communication is recorded in real time and recorded files are saved in a user's local device. This function applies to scenarios of recording during a call.
Overview
Recording by the client is defined as recording and saving the mixed audio stream in a room during a call in a user's local device for follow-up playback or as archiving. NERTC SDK supports real-time audio recording by client. For each recording, one audio file is generated, including the mixed audio stream data of all users in the room. After this function is enabled, users can specify the path and format for saving the recorded files, sample rate in recording, and audio quality.
Audio formats that are currently supported include:
- WAV: Large files with high audio fidelity.
- AAC: Small files with some quality loss.
Considerations
- Files need to be suffixed with the
.wavor.aac. - Recording shall not begin until users join a room.
- Client can run only one recording task at one time. During the recording, if the startAudioRecording is called repeatedly, the current recording task will be ended before restarting a new recording task.
- When the current user leaves the room, the recording will be automatically stopped. You may also call the stopAudioRecording at any time during the call to manually stop recording.
Method
-
Join a room and call startAudioRecording to start recording.
-
If you need to end the recording, call stopAudioRecording to manually stop recording.
If the recording is not ended manually, it will automatically stop when the client leaves the room.
-
Receive the onAudioRecording callback.
Sample code
String audioRecordFile = new File(BaseActivity.this.getExternalFilesDir("audio_record"), "xxxx.wav").getAbsolutePath();
int recordSampleRate = 32000;
NERtcEx.getInstance().startAudioRecording(audioRecordFile, recordSampleRate, NERtcConstants.AudioRecordingQuality.AUDIO_RECORDING_QUALITY_HIGH);





