feat(realtime): add preferredVideoCodec connect option#146
Conversation
Exposes a preferredVideoCodec ("h264" | "vp9") option on
realtime.connect() to control the local track publish codec.
VP9 publishes use a 2.6 Mbps cap; Safari remains pinned to vp8.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c263d3a to
1b67e4a
Compare
| if (safariCodec && preferredVideoCodec) { | ||
| logger.warn("preferredVideoCodec ignored on Desktop Safari; using vp8"); | ||
| } |
There was a problem hiding this comment.
lets drop it from here, and mention this in the docs? devs will need to do ugly tricks to make this warning disappear so let's help them not have to
- Set VP9 max bitrate to 3 Mbps. - Disable simulcast only for VP9 (SVC); keep simulcast on for h264/vp8/av1. - Drop the Safari override warn; document the fallback on the schema field instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0878f7c. Configure here.
| }, | ||
| defaultVideoCodec: "h264", | ||
| defaultMaxVideoBitrateBps: 3_500_000, | ||
| vp9MaxVideoBitrateBps: 3_000_000, |
There was a problem hiding this comment.
VP9 bitrate config contradicts documented intent
Medium Severity
The vp9MaxVideoBitrateBps config is set to 3_000_000 (3.0 Mbps), but the PR description explicitly states "VP9 publishes get a 2.6 Mbps maxBitrate cap" and the test plan verifies maxBitrate === 2_600_000. The implemented value doesn't match the documented intent — either the config value or the PR description needs to be reconciled.
Reviewed by Cursor Bugbot for commit 0878f7c. Configure here.
commit: |


Summary
preferredVideoCodec: "h264" | "vp9"torealtime.connect()options. Defaults toh264via existing config.maxBitratecap (newREALTIME_CONFIG.livekit.vp9MaxVideoBitrateBps); other codecs keep the 3.5 Mbps default.vp8; a warn log is emitted if a user value is ignored.livekit_server_codecquery param is untouched.packages/sdk/index.html) gets a codec dropdown in the publisher config section.Test plan
pnpm exec tsc --noEmitcleanpnpm test --run— 206/206 passingpackages/sdk/index.html, pickvp9, connect; verifyRTCRtpSender.getParameters().encodings[0].maxBitrate === 2_600_000and active codec is VP9 inchrome://webrtc-internalsh264(or default), confirmmaxBitrate === 3_500_000vp9, confirm warn log and thatvp8is published🤖 Generated with Claude Code
Note
Medium Risk
Changes WebRTC publish encoding (codec, bitrate, simulcast) on the realtime path; Safari override limits blast radius but wrong VP9 settings could affect stream quality or compatibility.
Overview
Adds optional
preferredVideoCodec(h264|vp9) onrealtime.connect()so callers can choose the LiveKit local camera publish codec; omitting it keeps the existing h264 default.Publish options now resolve codec explicitly: VP9 uses a 3 Mbps max bitrate (
vp9MaxVideoBitrateBps) and disables simulcast; other codecs keep 3.5 Mbps and simulcast. Desktop Safari still forces VP8 for publish (and thelivekit_server_codecquery param); user preference does not override that.The SDK test page adds a codec dropdown wired into connect for manual verification.
Reviewed by Cursor Bugbot for commit 0878f7c. Bugbot is set up for automated code reviews on this repo. Configure here.