The AgoraMediaRecorder class, for recording the audio and video on the client. AgoraMediaRecorder can record the following content:
- The audio captured by the local microphone and encoded in AAC format by the SDK.
- The video captured by the local camera and encoded by the SDK.
- Since
- v3.5.2
- Note
- In the
COMMUNICATION channel profile, this function is unavailable when there are users using versions of the SDK earlier than v3.0.0 in the channel.
Starts recording audio and video streams.
This method starts recording audio and video streams. The Agora SDK supports recording both local and remote users' audio and video streams simultaneously. Before starting the recording, make sure that:
- You have created a media recorder object using
createMediaRecorder.
- You have registered a media recorder observer using
setMediaRecorderObserver to listen for recording-related callbacks.
- You have joined a channel.
This method supports recording the following data:
- Audio captured by the microphone in AAC format.
- Video captured by the camera in H.264 or H.265 format.
After recording starts, if the video resolution changes during the recording process, the SDK stops the recording. If the audio sample rate or number of channels changes, the SDK continues recording and generates a single MP4 file. A recording file is successfully generated only when recordable audio or video streams are detected. If no recordable stream is available, or if the audio or video stream is interrupted for more than 5 seconds during recording, the SDK stops the recording and triggers the onRecorderStateChanged (RECORDER_STATE_ERROR, RECORDER_REASON_NO_STREAM) callback.
- Note
- If you want to record the local audio and video streams, make sure the local user role is set to broadcaster before starting the recording.
- If you want to record remote users' audio and video streams, make sure you have subscribed to the remote users' audio and video streams before starting the recording.
- Parameters
-
- Returns
- 0: The method call succeeds.
- < 0: The method call fails. See
Error Codes for details and troubleshooting.
- -2: Invalid parameter. Make sure that:
- The specified file path for saving the recording is correct and writable.
- The specified recording file format is correct.
- The maximum recording duration is set correctly.
- -4: The current state of
RtcEngine does not support this operation. This may occur if recording is already in progress or if it stopped due to an error.
- -7: The method is called before
RtcEngine is initialized. Make sure you have created the AgoraMediaRecorder object before calling this method.