Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Add configurable max FPS setting for screen capture
Richie McIlroy9c53a4805e10
diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rsindex 1b8c89c77..9bec1d4f7 100644--- a/apps/desktop/src-tauri/src/general_settings.rs+++ b/apps/desktop/src-tauri/src/general_settings.rs@@ -125,6 +125,8 @@ pub struct GeneralSettingsStore {pub default_project_name_template: Option<String>,#[serde(default = "default_true")]pub crash_recovery_recording: bool,+ #[serde(default = "default_max_fps")]+ pub max_fps: u32,}fn default_enable_native_camera_preview() -> bool {@@ -148,6 +150,10 @@ fn default_instant_mode_max_resolution() -> u32 {1920}+fn default_max_fps() -> u32 {+ 60+}+fn default_server_url() -> String {std::option_env!("VITE_SERVER_URL").unwrap_or("https://cap.so")@@ -192,6 +198,7 @@ impl Default for GeneralSettingsStore {instant_mode_max_resolution: 1920,default_project_name_template: None,crash_recovery_recording: true,+ max_fps: 60,}}}diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex 92d20b238..860e0e070 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -742,6 +742,9 @@ pub async fn start_recording(.as_ref().map(|s| s.crash_recovery_recording).unwrap_or_default(),+ )+ .with_max_fps(+ general_settings.as_ref().map(|s| s.max_fps).unwrap_or(60),);#[cfg(target_os = "macos")]diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsxindex 1f93cfa40..5c1cffbbc 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx@@ -82,6 +82,7 @@ const createDefaultGeneralSettings = (): ExtendedGeneralSettingsStore => ({excludedWindows: [],instantModeMaxResolution: 1920,crashRecoveryRecording: true,+ maxFps: 60,});const deriveInitialSettings = (@@ -106,6 +107,15 @@ const INSTANT_MODE_RESOLUTION_OPTIONS = [label: string;}[];+const MAX_FPS_OPTIONS = [+ { value: 30, label: "30 FPS" },+ { value: 60, label: "60 FPS (Recommended)" },+ { value: 120, label: "120 FPS" },+] satisfies {+ value: number;+ label: string;+}[];+const DEFAULT_PROJECT_NAME_TEMPLATE ="{target_name} ({target_kind}) {date} {time}";@@ -576,6 +586,24 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {value={settings.crashRecoveryRecording ?? true}onChange={(value) => handleChange("crashRecoveryRecording", value)}/>+ <div class="flex flex-col gap-1">+ <SelectSettingItem+ label="Max capture framerate"+ description="Maximum framerate for screen capture. Higher values may cause instability on some systems."+ value={settings.maxFps ?? 60}+ onChange={(value) => handleChange("maxFps", value)}+ options={MAX_FPS_OPTIONS.map((option) => ({+ text: option.label,+ value: option.value,+ }))}+ />+ {(settings.maxFps ?? 60) > 60 && (+ <p class="text-xs text-amber-500 px-1 pb-2">+ ⚠️ Higher framerates may cause frame drops or increased CPU usage+ on some systems.+ </p>+ )}+ </div></SettingGroup><DefaultProjectNameCarddiff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex 12bd0af6e..d85936906 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -420,7 +420,7 @@ export type ExportSettings = ({ format: "Mp4" } & Mp4ExportSettings) | ({ formatexport type FileType = "recording" | "screenshot"export type Flags = { captions: boolean }export type FramesRendered = { renderedCount: number; totalFrames: number; type: "FramesRendered" }-export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; custom_cursor_capture2?: boolean; serverUrl?: string; recordingCountdown?: number | null; enableNativeCameraPreview: boolean; autoZoomOnClicks?: boolean; enableNewRecordingFlow: boolean; recordingPickerPreferenceSet?: boolean; postDeletionBehaviour?: PostDeletionBehaviour; excludedWindows?: WindowExclusion[]; deleteInstantRecordingsAfterUpload?: boolean; instantModeMaxResolution?: number; defaultProjectNameTemplate?: string | null; crashRecoveryRecording?: boolean }+export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; custom_cursor_capture2?: boolean; serverUrl?: string; recordingCountdown?: number | null; enableNativeCameraPreview: boolean; autoZoomOnClicks?: boolean; enableNewRecordingFlow: boolean; recordingPickerPreferenceSet?: boolean; postDeletionBehaviour?: PostDeletionBehaviour; excludedWindows?: WindowExclusion[]; deleteInstantRecordingsAfterUpload?: boolean; instantModeMaxResolution?: number; defaultProjectNameTemplate?: string | null; crashRecoveryRecording?: boolean; maxFps?: number }export type GifExportSettings = { fps: number; resolution_base: XY<number>; quality: GifQuality | null }export type GifQuality = {/**diff --git a/crates/recording/src/studio_recording.rs b/crates/recording/src/studio_recording.rsindex bc437d3fb..3fe0cfb52 100644--- a/crates/recording/src/studio_recording.rs+++ b/crates/recording/src/studio_recording.rs@@ -455,6 +455,7 @@ pub struct ActorBuilder {camera_feed: Option<Arc<CameraFeedLock>>,custom_cursor: bool,fragmented: bool,+ max_fps: u32,#[cfg(target_os = "macos")]excluded_windows: Vec<scap_targets::WindowId>,}@@ -469,6 +470,7 @@ impl ActorBuilder {camera_feed: None,custom_cursor: false,fragmented: false,+ max_fps: 60,#[cfg(target_os = "macos")]excluded_windows: Vec::new(),}@@ -499,6 +501,11 @@ impl ActorBuilder {self}+ pub fn with_max_fps(mut self, max_fps: u32) -> Self {+ self.max_fps = max_fps.clamp(1, 120);+ self+ }+#[cfg(target_os = "macos")]pub fn with_excluded_windows(mut self, excluded_windows: Vec<scap_targets::WindowId>) -> Self {self.excluded_windows = excluded_windows;@@ -523,6 +530,7 @@ impl ActorBuilder {},self.custom_cursor,self.fragmented,+ self.max_fps,).await}@@ -534,6 +542,7 @@ async fn spawn_studio_recording_actor(base_inputs: RecordingBaseInputs,custom_cursor_capture: bool,fragmented: bool,+ max_fps: u32,) -> anyhow::Result<ActorHandle> {ensure_dir(&recording_dir)?;@@ -564,6 +573,7 @@ async fn spawn_studio_recording_actor(base_inputs.clone(),custom_cursor_capture,fragmented,+ max_fps,start_time,completion_tx.clone(),);@@ -620,8 +630,36 @@ async fn stop_recording() -> Result<CompletedRecording, RecordingError> {use cap_project::*;- let make_relative = |path: &PathBuf| {- RelativePathBuf::from_path(path.strip_prefix(&recording_dir).unwrap()).unwrap()+ const DEFAULT_FPS: u32 = 30;++ let make_relative = |path: &PathBuf| -> RelativePathBuf {+ match path.strip_prefix(&recording_dir) {+ Ok(stripped) => RelativePathBuf::from_path(stripped).unwrap_or_else(|_| {+ tracing::warn!(+ "Failed to convert path to relative: {:?}, using filename only",+ path+ );+ RelativePathBuf::from(+ path.file_name()+ .unwrap_or_default()+ .to_string_lossy()+ .as_ref(),+ )+ }),+ Err(_) => {+ tracing::warn!(+ "Path {:?} is not inside recording_dir {:?}, using filename only",+ path,+ recording_dir+ );+ RelativePathBuf::from(+ path.file_name()+ .unwrap_or_default()+ .to_string_lossy()+ .as_ref(),+ )+ }+ }};let segment_metas: Vec<_> = futures::stream::iter(segments)@@ -632,12 +670,29 @@ async fn stop_recording(MultipleSegment {display: VideoMeta {path: make_relative(&s.pipeline.screen.path),- fps: s.pipeline.screen.video_info.unwrap().fps(),+ fps: s+ .pipeline+ .screen+ .video_info+ .map(|v| v.fps())+ .unwrap_or_else(|| {+ tracing::warn!(+ "Screen video_info missing, using default fps: {}",+ DEFAULT_FPS+ );+ DEFAULT_FPS+ }),start_time: Some(to_start_time(s.pipeline.screen.first_timestamp)),},camera: s.pipeline.camera.map(|camera| VideoMeta {path: make_relative(&camera.path),- fps: camera.video_info.unwrap().fps(),+ fps: camera.video_info.map(|v| v.fps()).unwrap_or_else(|| {+ tracing::warn!(+ "Camera video_info missing, using default fps: {}",+ DEFAULT_FPS+ );+ DEFAULT_FPS+ }),start_time: Some(to_start_time(camera.first_timestamp)),}),mic: s.pipeline.microphone.map(|mic| AudioMeta {@@ -716,6 +771,7 @@ struct SegmentPipelineFactory {base_inputs: RecordingBaseInputs,custom_cursor_capture: bool,fragmented: bool,+ max_fps: u32,start_time: Timestamps,index: u32,completion_tx: watch::Sender<Option<Result<(), PipelineDoneError>>>,@@ -731,6 +787,7 @@ impl SegmentPipelineFactory {base_inputs: RecordingBaseInputs,custom_cursor_capture: bool,fragmented: bool,+ max_fps: u32,start_time: Timestamps,completion_tx: watch::Sender<Option<Result<(), PipelineDoneError>>>,) -> Self {@@ -740,6 +797,7 @@ impl SegmentPipelineFactory {base_inputs,custom_cursor_capture,fragmented,+ max_fps,start_time,index: 0,completion_tx,@@ -762,6 +820,7 @@ impl SegmentPipelineFactory {next_cursors_id,self.custom_cursor_capture,self.fragmented,+ self.max_fps,self.start_time,#[cfg(windows)]self.encoder_preferences.clone(),@@ -831,6 +890,7 @@ async fn create_segment_pipeline(next_cursors_id: u32,custom_cursor_capture: bool,fragmented: bool,+ max_fps: u32,start_time: Timestamps,#[cfg(windows)] encoder_preferences: crate::capture_pipeline::EncoderPreferences,) -> anyhow::Result<Pipeline> {@@ -840,8 +900,6 @@ async fn create_segment_pipeline(let (display, crop) =target_to_display_and_crop(&base_inputs.capture_target).context("target_display_crop")?;- let max_fps = if fragmented { 60 } else { 120 };-let screen_config = ScreenCaptureConfig::<ScreenCaptureMethod>::init(display,crop,