-
Notifications
You must be signed in to change notification settings - Fork 146
fix: improve initial video quality by setting x-google-start-bitrate for all video codecs #973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import io.livekit.android.room.Room | |
| import io.livekit.android.room.TrackBitrateInfo | ||
| import io.livekit.android.room.datastream.outgoing.OutgoingDataStreamManager | ||
| import io.livekit.android.room.isSVCCodec | ||
| import io.livekit.android.room.isVideoCodec | ||
| import io.livekit.android.room.rpc.RpcClientManager | ||
| import io.livekit.android.room.rpc.RpcManager | ||
| import io.livekit.android.room.rpc.RpcServerManager | ||
|
|
@@ -697,9 +698,9 @@ internal constructor( | |
| track.statsGetter = engine.createStatsGetter(transceiver.sender) | ||
|
|
||
| val finalOptions = options | ||
| // Handle trackBitrates | ||
| // Handle trackBitrates - apply start bitrate for all video codecs to prevent initial blurriness | ||
| if (encodings.isNotEmpty()) { | ||
| if (finalOptions is VideoTrackPublishOptions && isSVCCodec(finalOptions.videoCodec) && encodings.firstOrNull()?.maxBitrateBps != null) { | ||
| if (finalOptions is VideoTrackPublishOptions && isVideoCodec(finalOptions.videoCodec) && encodings.firstOrNull()?.maxBitrateBps != null) { | ||
| engine.registerTrackBitrateInfo( | ||
| cid = cid, | ||
| TrackBitrateInfo( | ||
|
|
@@ -1481,7 +1482,8 @@ data class VideoTrackPublishDefaults( | |
| override val videoCodec: String = VideoCodec.VP8.codecName, | ||
| override val scalabilityMode: String? = null, | ||
| override val backupCodec: BackupVideoCodec? = null, | ||
| override val degradationPreference: RtpParameters.DegradationPreference? = null, | ||
| // Default to MAINTAIN_RESOLUTION to prevent initial video blurriness | ||
| override val degradationPreference: RtpParameters.DegradationPreference? = RtpParameters.DegradationPreference.MAINTAIN_RESOLUTION, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flips the default for every video publisher, not just the slow-ramp case. |
||
| override val simulcastLayers: List<VideoPreset>? = null, | ||
| ) : BaseVideoTrackPublishOptions() | ||
|
|
||
|
|
@@ -1494,7 +1496,8 @@ data class VideoTrackPublishOptions( | |
| override val backupCodec: BackupVideoCodec? = null, | ||
| override val source: Track.Source? = null, | ||
| override val stream: String? = null, | ||
| override val degradationPreference: RtpParameters.DegradationPreference? = null, | ||
| // Default to MAINTAIN_RESOLUTION to prevent initial video blurriness | ||
| override val degradationPreference: RtpParameters.DegradationPreference? = RtpParameters.DegradationPreference.MAINTAIN_RESOLUTION, | ||
| override val simulcastLayers: List<VideoPreset>? = null, | ||
| ) : BaseVideoTrackPublishOptions(), TrackPublishOptions { | ||
| constructor( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching this gate from
isSVCCodectoisVideoCodecpulls simulcast codecs (VP8 by default, plus H264) into this path, butmaxBitrateis still taken fromencodings.first(). For simulcast,computeVideoEncodingsadds encodings smallest-to-largest (thesortedByDescending { calculateScaleDown }ordering), soencodings.first()is the lowest layer. A default 16:9 publish starts at H180 = 160 kbps.registerTrackBitrateInfofeeds that intoensureCodecBitrates, which writes a codec-levelx-google-start-bitrate/x-google-max-bitratefrom the low-layer value, capping the full-resolution layer far below its target. SVC kept a single full-bitrate encoding, which is why this was SVC-only before. For simulcast you'd need the top layer's bitrate (or to skip the codec-level cap).