Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(camera): request native macOS capture format

Richie McIlroy1fa5139c90ae
diff --git a/crates/camera/src/macos.rs b/crates/camera/src/macos.rs
index 8851c1f0d..417bb63ae 100644
--- a/crates/camera/src/macos.rs
+++ b/crates/camera/src/macos.rs
@@ -116,6 +116,7 @@ pub(super) fn start_capturing_impl(
let mut output = av::capture::VideoDataOutput::new();
let mut session = av::capture::Session::new();
let mut added_input = false;
+ let pixel_format = format.native().format_desc().media_sub_type();
session.configure(|s| {
if s.can_add_input(&input) {
@@ -135,6 +136,16 @@ pub(super) fn start_capturing_impl(
.into());
}
+ let video_settings = ns::Dictionary::with_keys_values(
+ &[cv::pixel_buffer_keys::pixel_format().as_ns()],
+ &[ns::Number::with_u32(pixel_format).as_id_ref()],
+ );
+ output
+ .set_video_settings(Some(video_settings.as_ref()))
+ .map_err(|err| {
+ AVFoundationError::Message(format!("Failed to set camera video settings: {err}"))
+ })?;
+
output.set_sample_buf_delegate(Some(delegate.as_ref()), Some(&queue));
// The device config must stay locked while running starts,