Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
perf(recording): limit camera-active studio capture load
Richie McIlroy35a9170283ba
diff --git a/crates/recording/src/studio_recording.rs b/crates/recording/src/studio_recording.rsindex 81514bf49..0622a3b47 100644--- a/crates/recording/src/studio_recording.rs+++ b/crates/recording/src/studio_recording.rs@@ -44,6 +44,11 @@ use std::{use tokio::{sync::watch, task::JoinHandle};use tracing::{Instrument, debug, error_span, info, trace, warn};+const CAMERA_ACTIVE_MAX_SCREEN_WIDTH: u32 = 1920;+const CAMERA_ACTIVE_MAX_SCREEN_HEIGHT: u32 = 1200;+const COMPATIBILITY_CAMERA_ACTIVE_MAX_SCREEN_WIDTH: u32 = 1600;+const COMPATIBILITY_CAMERA_ACTIVE_MAX_SCREEN_HEIGHT: u32 = 1000;+#[allow(clippy::large_enum_variant)]enum ActorState {Recording {@@ -1279,17 +1284,17 @@ async fn create_segment_pipeline(trace!("preparing segment pipeline {index}");- #[cfg(target_os = "macos")]- let shared_pause_state = if segment_fragmented {- Some(SharedPauseState::new(Arc::new(- std::sync::atomic::AtomicBool::new(false),- )))let camera_active = base_inputs.camera_feed.is_some();#[cfg(target_os = "macos")]let segment_fragmented = fragmented && !camera_active;#[cfg(not(target_os = "macos"))]let segment_fragmented = fragmented;+ #[cfg(target_os = "macos")]+ let shared_pause_state = if segment_fragmented {+ Some(SharedPauseState::new(Arc::new(+ std::sync::atomic::AtomicBool::new(false),+ )))} else {None};@@ -1348,12 +1353,34 @@ async fn create_segment_pipeline(let (display, crop) =target_to_display_and_crop(&capture_target).context("target_display_crop")?;+ let compatibility_quality = matches!(quality, crate::StudioQuality::Compatibility);+ let max_capture_size = if camera_active {+ if compatibility_quality {+ Some((+ COMPATIBILITY_CAMERA_ACTIVE_MAX_SCREEN_WIDTH,+ COMPATIBILITY_CAMERA_ACTIVE_MAX_SCREEN_HEIGHT,+ ))+ } else {+ Some((+ CAMERA_ACTIVE_MAX_SCREEN_WIDTH,+ CAMERA_ACTIVE_MAX_SCREEN_HEIGHT,+ ))+ }+ } else {+ None+ };+ let effective_max_fps = if compatibility_quality && camera_active {+ max_fps.min(24)+ } else {+ max_fps+ };let screen_config = ScreenCaptureConfig::<ScreenCaptureMethod>::init(display,crop,!custom_cursor_capture,- max_fps,+ effective_max_fps,+ max_capture_size,start_time.system_time(),base_inputs.capture_system_audio,#[cfg(windows)]@@ -1416,7 +1443,10 @@ async fn create_segment_pipeline(OutputPipeline::builder(dir.join("camera.mp4")).with_video::<sources::NativeCamera>(camera_feed).with_timestamps(start_time)- .build::<AVFoundationCameraMuxer>(AVFoundationCameraMuxerConfig::default())+ .build::<AVFoundationCameraMuxer>(AVFoundationCameraMuxerConfig {+ compatibility_quality: matches!(quality, crate::StudioQuality::Compatibility),+ ..Default::default()+ }).instrument(error_span!("camera-out")).await};