Composite recording
Updated
How to record audio and video in composite recording mode using command line.
The On-Premise Recording SDK supports two recording modes:
- Individual recording mode: This is the default recording mode. The SDK generates one audio and/or video file for each UID.
- Composite recording mode: Generates a single mixed audio and video file for all UIDs in a channel, or mixes the audio of all UIDs in the channel into an audio file and the video of all UIDs into a video file.
See Differences between individual recording mode and composite recording mode to decide which mode you should use.
Prerequisites
Before continuing, follow the Quickstart guide to integrate the Recording SDK and implement the basic recording functionality.
Implement composite recording
The implementation of composite recording is largely similar to the steps in the Quickstart guide. The main differences are in the configuration parameters and the APIs used.
Refer to the following call sequence diagram to understand the recording workflow.
Sequence diagram
To implement composite recording in your app, follow these steps:
- Initialize the recorder with
enableMixset totrue. - Subscribe to the audio and video streams of the users you want to record.
- Join the channel using
joinChannel. - After joining the channel:
- Use
setRecorderConfigto set video resolution, frame rate, duration, and output path. - Optionally, use
enableAndUpdateVideoWatermarksto apply video watermarks. - Use
setVideoMixingLayoutto configure the layout of multiple video streams.
- Use
- Start and stop recording using:
Refer to the following code to implement these steps:
// Initialize the recorder in composite recording mode
agoraMediaRtcRecorder.initialize(agoraService, true);
// Subscribe to all audio and video streams
agoraMediaRtcRecorder.subscribeAllAudio();
VideoSubscriptionOptions options = new VideoSubscriptionOptions();
options.setEncodedFrameOnly(false);
options.setType(Constants.VideoStreamType.VIDEO_STREAM_HIGH);
agoraMediaRtcRecorder.subscribeAllVideo(options);
// Join the channel
agoraMediaRtcRecorder.joinChannel(
recorderConfig.getToken(),
recorderConfig.getChannelName(),
recorderConfig.getUserId()
);
// Configure the recorder
agoraMediaRtcRecorder.setRecorderConfig(recorderConfig);
agoraMediaRtcRecorder.enableAndUpdateVideoWatermarks(watermarks); // Optional
agoraMediaRtcRecorder.setVideoMixingLayout(layout);
// Start recording
agoraMediaRtcRecorder.startRecording();
// ...
// Stop recording
agoraMediaRtcRecorder.stopRecording();Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
Considerations
The composite recording mode supports a specific set of APIs. Calling unsupported methods in the wrong mode has no effect. When using the composite recording mode, the following methods do not work:
