@@ -55,25 +55,43 @@ export class RecordAgoraStarted extends AbstractController<RequestType, Response
55
55
const { roomUUID, agoraParams, agoraData } = this . body ;
56
56
const userUUID = this . userUUID ;
57
57
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.
61
59
const transcodingConfig = agoraData . clientRequest . recordingConfig ?. transcodingConfig ;
62
60
if ( transcodingConfig ) {
63
- const { width, height } = transcodingConfig ;
61
+ let { width, height } = transcodingConfig ;
64
62
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
+ }
73
87
shouldUpdate = true ;
74
88
}
75
89
if ( shouldUpdate && agoraData . clientRequest . recordingConfig ) {
76
- agoraData . clientRequest . recordingConfig . transcodingConfig = transcodingConfig ;
90
+ agoraData . clientRequest . recordingConfig . transcodingConfig = {
91
+ ...transcodingConfig ,
92
+ width,
93
+ height,
94
+ } ;
77
95
}
78
96
}
79
97
0 commit comments