Problem
A developer is using Cloud Composite Recording to capture the audio and video of users who have joined a channel. However, when joining from a desktop, the recorded video appears cropped and in portrait mode. The developer attempted to use mixedVideoLayout: 1 (Best Fit Layout) to resolve the issue, but the problem persists. The request body is:
{
"cname": "7042813272738770944",
"uid": "2297905009",
"clientRequest": {
"token": "",
"storageConfig": {
"vendor": 6,
"region": 1,
"bucket": "live-call-recording",
"accessKey": "",
"secretKey": "",
"fileNamePrefix": [
"uploads",
"nineRecordings"
]
},
"recordingConfig": {
"channelType": 0,
"streamTypes": 2,
"streamMode": "default",
"videoStreamType": 0,
"maxIdleTime": 3600,
"subscribeVideoUids": [
"2297905008",
"1941217962"
],
"subscribeAudioUids": [
"2297905008",
"1941217962"
],
"subscribeUidGroup": 0,
"transcodingConfig": {
"width": 640,
"height": 480,
"fps": 15,
"bitrate": 500,
"mixedVideoLayout": 1
}
},
"recordingFileConfig": {
"avFileType": [
"hls",
"mp4"
]
}
}
}
Here is an example screenshot of the layout:
Root Cause
One of the user has the following send resolution:
Width: 480
Height: 640
This resolution (480 x 640) corresponds to an aspect ratio of 3:4 (portrait mode). However, he had set the recording dimensions to 640 x 480 (landscape mode), which corresponds to an aspect ratio of 4:3. Since the aspect ratios are different, the video may be resized or stretched to fit the landscape dimensions.
The behavior of the recorded video will depend on the layout configuration and how Agora handles the aspect ratio mismatch. This is expected behavior when using the best fit layout (mixedVideoLayout = 1). In the best fit layout, if the aspect ratio of a user's video does not match that of the target region, the video will be cropped to fit the region.
Reference: https://docs.agora.io/en/cloud-recording/develop/layout#best-fit-layout
Resolution
Developer should use the Customized layout (mixedVideoLayout:3) and set the render mode as 1: Scaled to fit mode. In customized layout, a developer can specify a custom layout for the video streams that will be recorded. This includes defining the position and size of each participant's video feed in the final recorded output.