livekit / rust-sdks

LiveKit realtime and server SDKs for Rust
https://livekit.io
Apache License 2.0
185 stars 44 forks source link

Correct issue that prevented publish_track from respecting the user defined video_encoding parameters #347

Closed Hunter-Dolan closed 3 months ago

Hunter-Dolan commented 3 months ago

Hello everyone!

When publishing a track, with the following code

let bitrate = 30_000_000;
let framerate: f64 = 60.0;

local_participant
    .publish_track(
        LocalTrack::Video(track.clone()),
        TrackPublishOptions {
            source: TrackSource::Camera,
            video_codec: VideoCodec::VP9,
            video_encoding: Some(VideoEncoding {
                max_bitrate: bitrate,
                max_framerate: framerate,
            }),
            dtx: false,
            red: false,
            simulcast: false,
            ..Default::default()
        },
    )
    .await
    .unwrap();

We determined that tracks were always getting limited to 30fps and approx 4mbps. After digging into the publish_track method it was determined that the user defined video_encoding parameters were getting thrown out in favor of the defaults.

This PR modifies the compute_appropriate_encoding to properly take into account the user defined encoding settings. After making this change we were able to reliably push 60fps @ 30mbps using VP8/VP9/AV1 and are no longer running into a cap.

CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.

theomonnom commented 3 months ago

Hey, it doesn't seems like I can push to this branch. I'll create a new PR with the right fix