From 04a32e756bf8a196a6e3dbf44c5ac667e088a427 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Tue, 14 May 2024 16:10:03 +0200 Subject: [PATCH 1/4] Account for spatial layers in default video encoding for SVC codecs --- src/room/participant/publishUtils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/room/participant/publishUtils.ts b/src/room/participant/publishUtils.ts index d8fa4417a1..56eb978d2b 100644 --- a/src/room/participant/publishUtils.ts +++ b/src/room/participant/publishUtils.ts @@ -118,6 +118,8 @@ export function computeVideoEncodings( return [{}]; } + let useDefaultVideoEncoding = !videoEncoding; + if (!videoEncoding) { // find the right encoding based on width/height videoEncoding = determineAppropriateEncoding(isScreenShare, width, height, videoCodec); @@ -163,8 +165,12 @@ export function computeVideoEncodings( /* @ts-ignore */ encodings[0].scalabilityMode = scalabilityMode; } else { + const svcBitrate = useDefaultVideoEncoding + ? // account for spatial layers if default video encoding computation has been used to determine bitrate + original.encoding.maxBitrate * Math.cbrt(sm.spatial) + : original.encoding.maxBitrate; encodings.push({ - maxBitrate: videoEncoding.maxBitrate, + maxBitrate: svcBitrate, maxFramerate: original.encoding.maxFramerate, /* @ts-ignore */ scalabilityMode: scalabilityMode, From cf33860d5009d3570380710adb6d7386de0dc216 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 15 May 2024 15:27:33 +0200 Subject: [PATCH 2/4] use new var in logic --- src/room/participant/publishUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/room/participant/publishUtils.ts b/src/room/participant/publishUtils.ts index 56eb978d2b..c84ef038b4 100644 --- a/src/room/participant/publishUtils.ts +++ b/src/room/participant/publishUtils.ts @@ -120,7 +120,7 @@ export function computeVideoEncodings( let useDefaultVideoEncoding = !videoEncoding; - if (!videoEncoding) { + if (useDefaultVideoEncoding) { // find the right encoding based on width/height videoEncoding = determineAppropriateEncoding(isScreenShare, width, height, videoCodec); log.debug('using video encoding', videoEncoding); From 577f212d083ad596d5c319f0d041fc10b2fbdbff Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 15 May 2024 15:29:01 +0200 Subject: [PATCH 3/4] Revert "use new var in logic" This reverts commit cf33860d5009d3570380710adb6d7386de0dc216. --- src/room/participant/publishUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/room/participant/publishUtils.ts b/src/room/participant/publishUtils.ts index c84ef038b4..56eb978d2b 100644 --- a/src/room/participant/publishUtils.ts +++ b/src/room/participant/publishUtils.ts @@ -120,7 +120,7 @@ export function computeVideoEncodings( let useDefaultVideoEncoding = !videoEncoding; - if (useDefaultVideoEncoding) { + if (!videoEncoding) { // find the right encoding based on width/height videoEncoding = determineAppropriateEncoding(isScreenShare, width, height, videoCodec); log.debug('using video encoding', videoEncoding); From 867adb6142062c3fadb238c11f4eb9aafb361dec Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 15 May 2024 16:21:55 +0200 Subject: [PATCH 4/4] Create orange-cobras-lie.md --- .changeset/orange-cobras-lie.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/orange-cobras-lie.md diff --git a/.changeset/orange-cobras-lie.md b/.changeset/orange-cobras-lie.md new file mode 100644 index 0000000000..1bea28f0c1 --- /dev/null +++ b/.changeset/orange-cobras-lie.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Account for spatial layers in default video encoding for SVC codecs