Skip to content

Commit c285913

Browse files
authored
fix(record): update agora record transcodingConfig limitation (#734)
1 parent 7ba8958 commit c285913

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

src/v1/controller/room/record/agora/Started.ts

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,43 @@ export class RecordAgoraStarted extends AbstractController<RequestType, Response
5555
const { roomUUID, agoraParams, agoraData } = this.body;
5656
const userUUID = this.userUUID;
5757

58-
// Limit transcodingConfig.width and transcodingConfig.height to 1920 and 1080 respectively.
59-
// Keep width height ratio.
60-
// Give config back to agoraData.
58+
// Limit width less than 1920 and greater than 96, height less than 1080 and greater than 96.
6159
const transcodingConfig = agoraData.clientRequest.recordingConfig?.transcodingConfig;
6260
if (transcodingConfig) {
63-
const { width, height } = transcodingConfig;
61+
let { width, height } = transcodingConfig;
6462
let shouldUpdate = false;
65-
if (width > 1920) {
66-
transcodingConfig.width = 1920;
67-
transcodingConfig.height = Math.floor((1920 / width) * height);
68-
shouldUpdate = true;
69-
}
70-
if (height > 1080) {
71-
transcodingConfig.height = 1080;
72-
transcodingConfig.width = Math.floor((1080 / height) * width);
63+
const minLength = 96;
64+
if (width > 1920 || height > 1080 || width < minLength || height < minLength) {
65+
if (width > 1920) {
66+
height = Math.floor((height * 1920) / width);
67+
width = 1920;
68+
}
69+
if (height > 1080) {
70+
width = Math.floor((width * 1080) / height);
71+
height = 1080;
72+
}
73+
if (width < minLength) {
74+
height = Math.floor((height * minLength) / width);
75+
width = minLength;
76+
}
77+
if (height < minLength) {
78+
width = Math.floor((width * minLength) / height);
79+
height = minLength;
80+
}
81+
if (width > 1920) {
82+
width = 1920;
83+
}
84+
if (height > 1080) {
85+
height = 1080;
86+
}
7387
shouldUpdate = true;
7488
}
7589
if (shouldUpdate && agoraData.clientRequest.recordingConfig) {
76-
agoraData.clientRequest.recordingConfig.transcodingConfig = transcodingConfig;
90+
agoraData.clientRequest.recordingConfig.transcodingConfig = {
91+
...transcodingConfig,
92+
width,
93+
height,
94+
};
7795
}
7896
}
7997

0 commit comments

Comments
 (0)