Skip to content

Fix initial video quality blurriness for all codecs#1197

Open
xianshijing-lk wants to merge 5 commits into
mainfrom
sxian/CLT-3068/fix-initial-video-quality-blurriness-by-setting-x-google-start-bitrate
Open

Fix initial video quality blurriness for all codecs#1197
xianshijing-lk wants to merge 5 commits into
mainfrom
sxian/CLT-3068/fix-initial-video-quality-blurriness-by-setting-x-google-start-bitrate

Conversation

@xianshijing-lk

Copy link
Copy Markdown
Contributor

Summary

Fixes initial video quality blurriness by:

  1. Applying x-google-start-bitrate SDP hint for all video codecs (VP8, VP9, AV1, H264, H265)
  2. Defaulting DegradationPreference to MaintainResolution for all video tracks

Problem

Users report video starting blurry for 5-15 seconds before reaching full quality (https://www.loom.com/share/9a34ae565f6949b891a155a436b3d573). This happens because:

  1. Slow bandwidth ramp-up: x-google-start-bitrate was only set for VP9/AV1, so VP8/H264 streams start at WebRTC's conservative default (~300 kbps) and ramp up slowly.
  2. Resolution degradation: Default DegradationPreference was Balanced, causing the encoder to reduce resolution during the ramp-up period.

Changes

livekit/src/rtc_engine/peer_transport.rs

  • Extended x-google-start-bitrate SDP munging to all video codecs (VP8, VP9, AV1, H264, H265)
  • Updated tests

libwebrtc/src/rtp_parameters.rs

  • Added DegradationPreference enum
  • Added set_degradation_preference() and degradation_preference() methods to RtpParameters

livekit/src/room/options.rs

  • Added degradation_preference field to TrackPublishOptions
  • Added get_default_degradation_preference() that defaults to MaintainResolution
  • Re-exported DegradationPreference for users

livekit/src/room/participant/local_participant.rs

  • Apply degradation preference to video tracks after creating the transceiver

Behavior
│ Setting │ Before │ After │
│ x-google-start-bitrate │ VP9/AV1 only │ All video codecs │
│ DegradationPreference │ Not set (WebRTC default) │ MaintainResolution │
Users can override degradation_preference in TrackPublishOptions if they prefer Balanced or MaintainFramerate.

Testing

  • Added unit tests for DegradationPreference defaults
  • Updated x-google-start-bitrate tests for all codecs
  • Manual testing with local_video example

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Changeset

The following package versions will be affected by this PR:

Package Bump
libwebrtc minor
livekit minor
livekit-ffi minor

@boks1971 boks1971 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

Comment thread livekit/src/rtc_engine/peer_transport.rs Outdated
@xianshijing-lk xianshijing-lk force-pushed the sxian/CLT-3068/fix-initial-video-quality-blurriness-by-setting-x-google-start-bitrate branch from bf4b429 to ac2f359 Compare June 29, 2026 10:09
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.

4 participants