Skip to content

feat(realtime): add preferredVideoCodec connect option#146

Merged
VerioN1 merged 3 commits into
mainfrom
feat/realtime-preferred-video-codec
May 26, 2026
Merged

feat(realtime): add preferredVideoCodec connect option#146
VerioN1 merged 3 commits into
mainfrom
feat/realtime-preferred-video-codec

Conversation

@VerioN1
Copy link
Copy Markdown
Contributor

@VerioN1 VerioN1 commented May 26, 2026

Summary

  • Add preferredVideoCodec: "h264" | "vp9" to realtime.connect() options. Defaults to h264 via existing config.
  • VP9 publishes get a 2.6 Mbps maxBitrate cap (new REALTIME_CONFIG.livekit.vp9MaxVideoBitrateBps); other codecs keep the 3.5 Mbps default.
  • Desktop Safari still force-pins vp8; a warn log is emitted if a user value is ignored.
  • Only affects the LiveKit publish codec — the Safari-only livekit_server_codec query param is untouched.
  • Test page (packages/sdk/index.html) gets a codec dropdown in the publisher config section.

Test plan

  • pnpm exec tsc --noEmit clean
  • pnpm test --run — 206/206 passing
  • Manual: load packages/sdk/index.html, pick vp9, connect; verify RTCRtpSender.getParameters().encodings[0].maxBitrate === 2_600_000 and active codec is VP9 in chrome://webrtc-internals
  • Manual: pick h264 (or default), confirm maxBitrate === 3_500_000
  • Manual on Desktop Safari: pick vp9, confirm warn log and that vp8 is 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) on realtime.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 the livekit_server_codec query 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.

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>
Comment thread packages/sdk/src/realtime/media-channel.ts Outdated
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@VerioN1 VerioN1 force-pushed the feat/realtime-preferred-video-codec branch from c263d3a to 1b67e4a Compare May 26, 2026 12:31
Comment thread packages/sdk/src/realtime/client.ts Outdated
Comment on lines +151 to +153
if (safariCodec && preferredVideoCodec) {
logger.warn("preferredVideoCodec ignored on Desktop Safari; using vp8");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0878f7c. Configure here.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@decartai/sdk@146

commit: 0878f7c

@VerioN1 VerioN1 merged commit b9e9aa6 into main May 26, 2026
6 of 8 checks passed
@VerioN1 VerioN1 deleted the feat/realtime-preferred-video-codec branch May 26, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants