diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 3b61f4f..2bf82df 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -12,17 +12,17 @@ tokio.workspace = true quinn = { workspace = true, features = ["rustls-ring"] } gpui-kit = { version = "0.11.0", features = ["syntect"] } -ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } +ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } ureq = "3.5.2" bytes = "1.12.2" tracing = "0.1.44" diff --git a/crates/client/src/share/encode.rs b/crates/client/src/share/encode.rs index daf78f5..f539f64 100644 --- a/crates/client/src/share/encode.rs +++ b/crates/client/src/share/encode.rs @@ -149,10 +149,14 @@ mod hardware { pub struct Encoder(ec_hw::HwEncoder); + fn average(ceiling: u32) -> u32 { + ceiling / 3 * 2 + } + impl Encoder { pub fn tune(&mut self, bitrate: u32, fps: u32) { report(self.0.tune(ec_hw::Tunings { - bitrate, + bitrate: average(bitrate), framerate: (fps, 1), })); } @@ -229,9 +233,9 @@ mod hardware { }; let mut config = ec_hw::EncoderConfig::new(codec, settings.width, settings.height); config.framerate = (settings.fps, 1); - config.bitrate = settings.bitrate; + config.bitrate = average(settings.bitrate); config.gop_size = settings.gop; - config.rate_control = ec_hw::RateControlMode::ConstantBitrate; + config.rate_control = ec_hw::RateControlMode::VariableBitrate; let encoder = report(ec_hw::HwEncoder::open(config, None))?; tracing::info!(backend = ?encoder.backend(), ?codec, "share hardware encoder opened"); Some(Encoder(encoder)) diff --git a/crates/common/src/share.rs b/crates/common/src/share.rs index 05bc487..8f210f7 100644 --- a/crates/common/src/share.rs +++ b/crates/common/src/share.rs @@ -31,9 +31,10 @@ impl Codec { pub fn bits_per_pixel(self) -> f32 { match self { - Self::H264 | Self::Vp8 => 0.1, - Self::H265 | Self::Vp9 => 0.07, - Self::Av1 => 0.06, + Self::Vp8 => 0.1, + Self::H264 => 0.09, + Self::Vp9 => 0.07, + Self::H265 | Self::Av1 => 0.06, } } }