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 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,