From e452fdb39e1ca2479e09adf956322be3a99981d9 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Mon, 13 Oct 2025 14:28:18 +0800 Subject: [PATCH 1/2] use rec709 color space in cap_enc_avfoundation --- Cargo.lock | 4 ++++ Cargo.toml | 2 +- apps/desktop/src-tauri/src/recording.rs | 4 ++-- crates/enc-avfoundation/Cargo.toml | 2 +- crates/enc-avfoundation/src/mp4.rs | 26 ++++++++++++++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c18d5f363..926923cfbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1431,6 +1431,10 @@ dependencies = [ "windows-core 0.60.1", ] +[[package]] +name = "cap-multi-recorder" +version = "0.1.0" + [[package]] name = "cap-project" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index dc023746e9..95de187293 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["apps/cli", "apps/desktop/src-tauri", "crates/*"] +members = ["apps/cli", "apps/desktop/src-tauri", "apps/multi-recorder", "crates/*"] [workspace.dependencies] anyhow = { version = "1.0.86" } diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs index 8db9417449..625f3ecf6c 100644 --- a/apps/desktop/src-tauri/src/recording.rs +++ b/apps/desktop/src-tauri/src/recording.rs @@ -485,8 +485,8 @@ pub async fn start_recording( ) .await .map_err(|e| { - error!("Failed to spawn studio recording actor: {e}"); - e.to_string() + error!("Failed to spawn studio recording actor: {e:#}"); + format!("{e:#}") })?; InProgressRecording::Studio { handle, common } diff --git a/crates/enc-avfoundation/Cargo.toml b/crates/enc-avfoundation/Cargo.toml index 244a3e41a6..80b8094b71 100644 --- a/crates/enc-avfoundation/Cargo.toml +++ b/crates/enc-avfoundation/Cargo.toml @@ -11,7 +11,7 @@ thiserror.workspace = true tracing.workspace = true [target.'cfg(target_os = "macos")'.dependencies] -cidre = { workspace = true } +cidre = { workspace = true, features = ["vt"] } [lints] workspace = true diff --git a/crates/enc-avfoundation/src/mp4.rs b/crates/enc-avfoundation/src/mp4.rs index 388b00254f..f65d89bbea 100644 --- a/crates/enc-avfoundation/src/mp4.rs +++ b/crates/enc-avfoundation/src/mp4.rs @@ -125,6 +125,23 @@ impl MP4Encoder { .as_id_ref(), ); + output_settings.insert( + av::video_settings_keys::color_props(), + ns::Dictionary::with_keys_values( + &[ + unsafe { AVVideoTransferFunctionKey }, + unsafe { AVVideoColorPrimariesKey }, + unsafe { AVVideoYCbCrMatrixKey }, + ], + &[ + unsafe { AVVideoTransferFunction_ITU_R_709_2 }, + unsafe { AVVideoColorPrimaries_ITU_R_709_2 }, + unsafe { AVVideoYCbCrMatrix_ITU_R_709_2 }, + ], + ) + .as_id_ref(), + ); + let mut video_input = av::AssetWriterInput::with_media_type_and_output_settings( av::MediaType::video(), Some(output_settings.as_ref()), @@ -370,7 +387,14 @@ impl Drop for MP4Encoder { #[link(name = "AVFoundation", kind = "framework")] unsafe extern "C" { - static AVVideoAverageBitRateKey: &'static cidre::ns::String; + static AVVideoAverageBitRateKey: &'static ns::String; + static AVVideoTransferFunctionKey: &'static ns::String; + static AVVideoColorPrimariesKey: &'static ns::String; + static AVVideoYCbCrMatrixKey: &'static ns::String; + + static AVVideoTransferFunction_ITU_R_709_2: &'static cidre::ns::String; + static AVVideoColorPrimaries_ITU_R_709_2: &'static cidre::ns::String; + static AVVideoYCbCrMatrix_ITU_R_709_2: &'static cidre::ns::String; } unsafe fn result_unchecked(op: impl FnOnce(&mut Option) -> R) -> cidre::os::Result From d4b98b5ce104bef3601c995938f7b53ddd164459 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Mon, 13 Oct 2025 14:36:00 +0800 Subject: [PATCH 2/2] cleanup --- Cargo.lock | 4 ---- Cargo.toml | 2 +- crates/enc-avfoundation/Cargo.toml | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 926923cfbe..0c18d5f363 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1431,10 +1431,6 @@ dependencies = [ "windows-core 0.60.1", ] -[[package]] -name = "cap-multi-recorder" -version = "0.1.0" - [[package]] name = "cap-project" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 95de187293..dc023746e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["apps/cli", "apps/desktop/src-tauri", "apps/multi-recorder", "crates/*"] +members = ["apps/cli", "apps/desktop/src-tauri", "crates/*"] [workspace.dependencies] anyhow = { version = "1.0.86" } diff --git a/crates/enc-avfoundation/Cargo.toml b/crates/enc-avfoundation/Cargo.toml index 80b8094b71..244a3e41a6 100644 --- a/crates/enc-avfoundation/Cargo.toml +++ b/crates/enc-avfoundation/Cargo.toml @@ -11,7 +11,7 @@ thiserror.workspace = true tracing.workspace = true [target.'cfg(target_os = "macos")'.dependencies] -cidre = { workspace = true, features = ["vt"] } +cidre = { workspace = true } [lints] workspace = true