Set video layout
Updated
Learn how to set the video layout for composite recording with the Agora Recording SDK.
This guide shows you how to configure the video layout during composite recording using the On-Premise Recording SDK.
Understand the tech
In composite recording mode, the SDK renders the final video on a canvas that includes multiple user video streams. Each stream is placed in a defined region of the canvas. The canvas acts as the background, and you specify the dimensions and position of each user’s video.
The aspect ratio of a user's video must match that of the assigned region. If the aspect ratios differ, the SDK crops the video, which can result in image loss.
Prerequisites
Before using layouts, complete the steps in the Quickstart guide to integrate the SDK and set up basic recording.
Implementation
To configure the layout, call the setVideoMixingLayout method and pass a VideoMixingLayout object that defines:
- Canvas dimensions and frame rate
- Background color or image
- Layouts for each user's video
struct VideoMixingLayout recorderLayout;
recorderLayout.canvasWidth = 1280;
recorderLayout.canvasHeight = 720;
recorderLayout.canvasFps = 25;
UserMixerLayout layout[2];
layout[0].userId = "1234";
layout[0].config.x = 0;
layout[0].config.y = 0;
layout[0].config.width = 640;
layout[0].config.height = 360;
layout[1].userId = "5678";
layout[1].config.x = 720;
layout[1].config.y = 270;
layout[1].config.width = 540;
layout[1].config.height = 320;
recorderLayout.userLayoutConfigNum = 2;
recorderLayout.userLayoutConfigs = layout;
recorder->setVideoMixingLayout(recorderLayout);The sample code creates the following composite layout:
