Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add disk space monitoring to segmented video encoders

Richie McIlroy700f56aaa4dc
diff --git a/Cargo.lock b/Cargo.lock
index 90a9a5dd1..1af07ad78 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1333,6 +1333,7 @@ dependencies = [
"ffmpeg-next",
"serde",
"serde_json",
+ "sysinfo",
"thiserror 1.0.69",
"tracing",
"workspace-hack",
@@ -5541,6 +5542,15 @@ dependencies = [
"zbus",
]
+[[package]]
+name = "ntapi"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c70f219e21142367c70c0b30c6a9e3a14d55b4d12a204d897fbec83a0363f081"
+dependencies = [
+ "winapi",
+]
+
[[package]]
name = "nu-ansi-term"
version = "0.50.1"
@@ -8887,6 +8897,20 @@ dependencies = [
"libc",
]
+[[package]]
+name = "sysinfo"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c33cd241af0f2e9e3b5c32163b873b29956890b5342e6745b917ce9d490f4af"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+ "memchr",
+ "ntapi",
+ "rayon",
+ "windows 0.54.0",
+]
+
[[package]]
name = "system-configuration"
version = "0.5.1"
diff --git a/Cargo.toml b/Cargo.toml
index 61e8ab20f..777ba79a1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -71,6 +71,7 @@ windows-core = "0.60"
windows-sys = "0.59.0"
windows-capture = "1.5.0"
percent-encoding = "2.3.1"
+sysinfo = "0.32"
# TODO: Reenable these: https://github.com/CapSoftware/Cap/issues/859
[workspace.lints.rust]
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index 4265cbcdf..92d20b238 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -340,12 +340,25 @@ pub enum RecordingInputKind {
#[derive(tauri_specta::Event, specta::Type, Clone, Debug, serde::Serialize)]
#[serde(tag = "variant")]
pub enum RecordingEvent {
- Countdown { value: u32 },
+ Countdown {
+ value: u32,
+ },
Started,
Stopped,
- Failed { error: String },
- InputLost { input: RecordingInputKind },
- InputRestored { input: RecordingInputKind },
+ Failed {
+ error: String,
+ },
+ InputLost {
+ input: RecordingInputKind,
+ },
+ InputRestored {
+ input: RecordingInputKind,
+ },
+ DiskSpaceLow {
+ available_mb: u32,
+ threshold_mb: u32,
+ path: String,
+ },
}
#[derive(Serialize, Type)]
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index 18ba0fbe6..e69de29bb 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -1,588 +0,0 @@
-
-// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
-
-/** user-defined commands **/
-
-
-export const commands = {
-async setMicInput(label: string | null) : Promise<null> {
- return await TAURI_INVOKE("set_mic_input", { label });
-},
-async setCameraInput(id: DeviceOrModelID | null) : Promise<null> {
- return await TAURI_INVOKE("set_camera_input", { id });
-},
-async setRecordingMode(mode: RecordingMode) : Promise<null> {
- return await TAURI_INVOKE("set_recording_mode", { mode });
-},
-async uploadLogs() : Promise<null> {
- return await TAURI_INVOKE("upload_logs");
-},
-async getSystemDiagnostics() : Promise<SystemDiagnostics> {
- return await TAURI_INVOKE("get_system_diagnostics");
-},
-async startRecording(inputs: StartRecordingInputs) : Promise<RecordingAction> {
- return await TAURI_INVOKE("start_recording", { inputs });
-},
-async stopRecording() : Promise<null> {
- return await TAURI_INVOKE("stop_recording");
-},
-async pauseRecording() : Promise<null> {
- return await TAURI_INVOKE("pause_recording");
-},
-async resumeRecording() : Promise<null> {
- return await TAURI_INVOKE("resume_recording");
-},
-async restartRecording() : Promise<RecordingAction> {
- return await TAURI_INVOKE("restart_recording");
-},
-async deleteRecording() : Promise<null> {
- return await TAURI_INVOKE("delete_recording");
-},
-async takeScreenshot(target: ScreenCaptureTarget) : Promise<string> {
- return await TAURI_INVOKE("take_screenshot", { target });
-},
-async listCameras() : Promise<CameraInfo[]> {
- return await TAURI_INVOKE("list_cameras");
-},
-async listCaptureWindows() : Promise<CaptureWindow[]> {
- return await TAURI_INVOKE("list_capture_windows");
-},
-async listCaptureDisplays() : Promise<CaptureDisplay[]> {
- return await TAURI_INVOKE("list_capture_displays");
-},
-async listDisplaysWithThumbnails() : Promise<CaptureDisplayWithThumbnail[]> {
- return await TAURI_INVOKE("list_displays_with_thumbnails");
-},
-async listWindowsWithThumbnails() : Promise<CaptureWindowWithThumbnail[]> {
- return await TAURI_INVOKE("list_windows_with_thumbnails");
-},
-async refreshWindowContentProtection() : Promise<null> {
- return await TAURI_INVOKE("refresh_window_content_protection");
-},
-async getDefaultExcludedWindows() : Promise<WindowExclusion[]> {
- return await TAURI_INVOKE("get_default_excluded_windows");
-},
-async listAudioDevices() : Promise<string[]> {
- return await TAURI_INVOKE("list_audio_devices");
-},
-async closeRecordingsOverlayWindow() : Promise<void> {
- await TAURI_INVOKE("close_recordings_overlay_window");
-},
-async setFakeWindowBounds(name: string, bounds: LogicalBounds) : Promise<null> {
- return await TAURI_INVOKE("set_fake_window_bounds", { name, bounds });
-},
-async removeFakeWindow(name: string) : Promise<null> {
- return await TAURI_INVOKE("remove_fake_window", { name });
-},
-async focusCapturesPanel() : Promise<void> {
- await TAURI_INVOKE("focus_captures_panel");
-},
-async getCurrentRecording() : Promise<JsonValue<CurrentRecording | null>> {
- return await TAURI_INVOKE("get_current_recording");
-},
-async exportVideo(projectPath: string, progress: TAURI_CHANNEL<FramesRendered>, settings: ExportSettings) : Promise<string> {
- return await TAURI_INVOKE("export_video", { projectPath, progress, settings });
-},
-async getExportEstimates(path: string, settings: ExportSettings) : Promise<ExportEstimates> {
- return await TAURI_INVOKE("get_export_estimates", { path, settings });
-},
-async generateExportPreview(projectPath: string, frameTime: number, settings: ExportPreviewSettings) : Promise<ExportPreviewResult> {
- return await TAURI_INVOKE("generate_export_preview", { projectPath, frameTime, settings });
-},
-async generateExportPreviewFast(frameTime: number, settings: ExportPreviewSettings) : Promise<ExportPreviewResult> {
- return await TAURI_INVOKE("generate_export_preview_fast", { frameTime, settings });
-},
-async copyFileToPath(src: string, dst: string) : Promise<null> {
- return await TAURI_INVOKE("copy_file_to_path", { src, dst });
-},
-async copyVideoToClipboard(path: string) : Promise<null> {
- return await TAURI_INVOKE("copy_video_to_clipboard", { path });
-},
-async copyScreenshotToClipboard(path: string) : Promise<null> {
- return await TAURI_INVOKE("copy_screenshot_to_clipboard", { path });
-},
-async copyImageToClipboard(data: number[]) : Promise<null> {
- return await TAURI_INVOKE("copy_image_to_clipboard", { data });
-},
-async openFilePath(path: string) : Promise<null> {
- return await TAURI_INVOKE("open_file_path", { path });
-},
-async getVideoMetadata(path: string) : Promise<VideoRecordingMetadata> {
- return await TAURI_INVOKE("get_video_metadata", { path });
-},
-async createEditorInstance() : Promise<SerializedEditorInstance> {
- return await TAURI_INVOKE("create_editor_instance");
-},
-async getMicWaveforms() : Promise<number[][]> {
- return await TAURI_INVOKE("get_mic_waveforms");
-},
-async getSystemAudioWaveforms() : Promise<number[][]> {
- return await TAURI_INVOKE("get_system_audio_waveforms");
-},
-async startPlayback(fps: number, resolutionBase: XY<number>) : Promise<null> {
- return await TAURI_INVOKE("start_playback", { fps, resolutionBase });
-},
-async stopPlayback() : Promise<null> {
- return await TAURI_INVOKE("stop_playback");
-},
-async setPlayheadPosition(frameNumber: number) : Promise<null> {
- return await TAURI_INVOKE("set_playhead_position", { frameNumber });
-},
-async setProjectConfig(config: ProjectConfiguration) : Promise<null> {
- return await TAURI_INVOKE("set_project_config", { config });
-},
-async updateProjectConfigInMemory(config: ProjectConfiguration) : Promise<null> {
- return await TAURI_INVOKE("update_project_config_in_memory", { config });
-},
-async generateZoomSegmentsFromClicks() : Promise<ZoomSegment[]> {
- return await TAURI_INVOKE("generate_zoom_segments_from_clicks");
-},
-async openPermissionSettings(permission: OSPermission) : Promise<void> {
- await TAURI_INVOKE("open_permission_settings", { permission });
-},
-async doPermissionsCheck(initialCheck: boolean) : Promise<OSPermissionsCheck> {
- return await TAURI_INVOKE("do_permissions_check", { initialCheck });
-},
-async requestPermission(permission: OSPermission) : Promise<void> {
- await TAURI_INVOKE("request_permission", { permission });
-},
-async uploadExportedVideo(path: string, mode: UploadMode, channel: TAURI_CHANNEL<UploadProgress>, organizationId: string | null) : Promise<UploadResult> {
- return await TAURI_INVOKE("upload_exported_video", { path, mode, channel, organizationId });
-},
-async uploadScreenshot(screenshotPath: string) : Promise<UploadResult> {
- return await TAURI_INVOKE("upload_screenshot", { screenshotPath });
-},
-async createScreenshotEditorInstance() : Promise<SerializedScreenshotEditorInstance> {
- return await TAURI_INVOKE("create_screenshot_editor_instance");
-},
-async updateScreenshotConfig(config: ProjectConfiguration, save: boolean) : Promise<null> {
- return await TAURI_INVOKE("update_screenshot_config", { config, save });
-},
-async getRecordingMeta(path: string, fileType: FileType) : Promise<RecordingMetaWithMetadata> {
- return await TAURI_INVOKE("get_recording_meta", { path, fileType });
-},
-async saveFileDialog(fileName: string, fileType: string) : Promise<string | null> {
- return await TAURI_INVOKE("save_file_dialog", { fileName, fileType });
-},
-async listRecordings() : Promise<([string, RecordingMetaWithMetadata])[]> {
- return await TAURI_INVOKE("list_recordings");
-},
-async listScreenshots() : Promise<([string, RecordingMeta])[]> {
- return await TAURI_INVOKE("list_screenshots");
-},
-async checkUpgradedAndUpdate() : Promise<boolean> {
- return await TAURI_INVOKE("check_upgraded_and_update");
-},
-async openExternalLink(url: string) : Promise<null> {
- return await TAURI_INVOKE("open_external_link", { url });
-},
-async setHotkey(action: HotkeyAction, hotkey: Hotkey | null) : Promise<null> {
- return await TAURI_INVOKE("set_hotkey", { action, hotkey });
-},
-async resetCameraPermissions() : Promise<null> {
- return await TAURI_INVOKE("reset_camera_permissions");
-},
-async resetMicrophonePermissions() : Promise<null> {
- return await TAURI_INVOKE("reset_microphone_permissions");
-},
-async isCameraWindowOpen() : Promise<boolean> {
- return await TAURI_INVOKE("is_camera_window_open");
-},
-async seekTo(frameNumber: number) : Promise<null> {
- return await TAURI_INVOKE("seek_to", { frameNumber });
-},
-async positionTrafficLights(controlsInset: [number, number] | null) : Promise<void> {
- await TAURI_INVOKE("position_traffic_lights", { controlsInset });
-},
-async setTheme(theme: AppTheme) : Promise<void> {
- await TAURI_INVOKE("set_theme", { theme });
-},
-async globalMessageDialog(message: string) : Promise<void> {
- await TAURI_INVOKE("global_message_dialog", { message });
-},
-async showWindow(window: ShowCapWindow) : Promise<null> {
- return await TAURI_INVOKE("show_window", { window });
-},
-async writeClipboardString(text: string) : Promise<null> {
- return await TAURI_INVOKE("write_clipboard_string", { text });
-},
-async performHapticFeedback(pattern: HapticPattern | null, time: HapticPerformanceTime | null) : Promise<null> {
- return await TAURI_INVOKE("perform_haptic_feedback", { pattern, time });
-},
-/**
- * Check if system audio capture is supported on the current platform and OS version.
- * On macOS, system audio capture requires macOS 13.0 or later.
- * On Windows/Linux, this may have different requirements.
- */
-async isSystemAudioCaptureSupported() : Promise<boolean> {
- return await TAURI_INVOKE("is_system_audio_capture_supported");
-},
-async listFails() : Promise<{ [key in string]: boolean }> {
- return await TAURI_INVOKE("list_fails");
-},
-async setFail(name: string, value: boolean) : Promise<void> {
- await TAURI_INVOKE("set_fail", { name, value });
-},
-async updateAuthPlan() : Promise<void> {
- await TAURI_INVOKE("update_auth_plan");
-},
-async setWindowTransparent(value: boolean) : Promise<void> {
- await TAURI_INVOKE("set_window_transparent", { value });
-},
-async getEditorMeta() : Promise<RecordingMeta> {
- return await TAURI_INVOKE("get_editor_meta");
-},
-async setPrettyName(prettyName: string) : Promise<null> {
- return await TAURI_INVOKE("set_pretty_name", { prettyName });
-},
-async setServerUrl(serverUrl: string) : Promise<null> {
- return await TAURI_INVOKE("set_server_url", { serverUrl });
-},
-async setCameraPreviewState(state: CameraPreviewState) : Promise<null> {
- return await TAURI_INVOKE("set_camera_preview_state", { state });
-},
-async awaitCameraPreviewReady() : Promise<boolean> {
- return await TAURI_INVOKE("await_camera_preview_ready");
-},
-async createDir(path: string, recursive: boolean) : Promise<null> {
- return await TAURI_INVOKE("create_dir", { path, recursive });
-},
-async saveModelFile(path: string, data: number[]) : Promise<null> {
- return await TAURI_INVOKE("save_model_file", { path, data });
-},
-async prewarmWhisperx(modelPath: string) : Promise<boolean> {
- return await TAURI_INVOKE("prewarm_whisperx", { modelPath });
-},
-async transcribeAudio(videoPath: string, modelPath: string, language: string) : Promise<CaptionData> {
- return await TAURI_INVOKE("transcribe_audio", { videoPath, modelPath, language });
-},
-async saveCaptions(videoId: string, captions: CaptionData) : Promise<null> {
- return await TAURI_INVOKE("save_captions", { videoId, captions });
-},
-async loadCaptions(videoId: string) : Promise<CaptionData | null> {
- return await TAURI_INVOKE("load_captions", { videoId });
-},
-async downloadWhisperModel(modelName: string, outputPath: string) : Promise<null> {
- return await TAURI_INVOKE("download_whisper_model", { modelName, outputPath });
-},
-async checkModelExists(modelPath: string) : Promise<boolean> {
- return await TAURI_INVOKE("check_model_exists", { modelPath });
-},
-async deleteWhisperModel(modelPath: string) : Promise<null> {
- return await TAURI_INVOKE("delete_whisper_model", { modelPath });
-},
-async exportCaptionsSrt(videoId: string) : Promise<string | null> {
- return await TAURI_INVOKE("export_captions_srt", { videoId });
-},
-async openTargetSelectOverlays(focusedTarget: ScreenCaptureTarget | null) : Promise<null> {
- return await TAURI_INVOKE("open_target_select_overlays", { focusedTarget });
-},
-async closeTargetSelectOverlays() : Promise<null> {
- return await TAURI_INVOKE("close_target_select_overlays");
-},
-async updateCameraOverlayBounds(x: number, y: number, width: number, height: number) : Promise<null> {
- return await TAURI_INVOKE("update_camera_overlay_bounds", { x, y, width, height });
-},
-async displayInformation(displayId: string) : Promise<DisplayInformation> {
- return await TAURI_INVOKE("display_information", { displayId });
-},
-async getWindowIcon(windowId: string) : Promise<string | null> {
- return await TAURI_INVOKE("get_window_icon", { windowId });
-},
-async focusWindow(windowId: WindowId) : Promise<null> {
- return await TAURI_INVOKE("focus_window", { windowId });
-},
-async editorDeleteProject() : Promise<null> {
- return await TAURI_INVOKE("editor_delete_project");
-},
-async formatProjectName(template: string | null, targetName: string, targetKind: string, recordingMode: RecordingMode, datetime: string | null) : Promise<string> {
- return await TAURI_INVOKE("format_project_name", { template, targetName, targetKind, recordingMode, datetime });
-},
-async findIncompleteRecordings() : Promise<IncompleteRecordingInfo[]> {
- return await TAURI_INVOKE("find_incomplete_recordings");
-},
-async recoverRecording(projectPath: string) : Promise<string> {
- return await TAURI_INVOKE("recover_recording", { projectPath });
-},
-async discardIncompleteRecording(projectPath: string) : Promise<null> {
- return await TAURI_INVOKE("discard_incomplete_recording", { projectPath });
-}
-}
-
-/** user-defined events **/
-
-
-export const events = __makeEvents__<{
-audioInputLevelChange: AudioInputLevelChange,
-currentRecordingChanged: CurrentRecordingChanged,
-downloadProgress: DownloadProgress,
-editorStateChanged: EditorStateChanged,
-newNotification: NewNotification,
-newScreenshotAdded: NewScreenshotAdded,
-newStudioRecordingAdded: NewStudioRecordingAdded,
-onEscapePress: OnEscapePress,
-recordingDeleted: RecordingDeleted,
-recordingEvent: RecordingEvent,
-recordingOptionsChanged: RecordingOptionsChanged,
-recordingStarted: RecordingStarted,
-recordingStopped: RecordingStopped,
-renderFrameEvent: RenderFrameEvent,
-requestOpenRecordingPicker: RequestOpenRecordingPicker,
-requestOpenSettings: RequestOpenSettings,
-requestScreenCapturePrewarm: RequestScreenCapturePrewarm,
-requestStartRecording: RequestStartRecording,
-setCaptureAreaPending: SetCaptureAreaPending,
-targetUnderCursor: TargetUnderCursor,
-uploadProgressEvent: UploadProgressEvent
-}>({
-audioInputLevelChange: "audio-input-level-change",
-currentRecordingChanged: "current-recording-changed",
-downloadProgress: "download-progress",
-editorStateChanged: "editor-state-changed",
-newNotification: "new-notification",
-newScreenshotAdded: "new-screenshot-added",
-newStudioRecordingAdded: "new-studio-recording-added",
-onEscapePress: "on-escape-press",
-recordingDeleted: "recording-deleted",
-recordingEvent: "recording-event",
-recordingOptionsChanged: "recording-options-changed",
-recordingStarted: "recording-started",
-recordingStopped: "recording-stopped",
-renderFrameEvent: "render-frame-event",
-requestOpenRecordingPicker: "request-open-recording-picker",
-requestOpenSettings: "request-open-settings",
-requestScreenCapturePrewarm: "request-screen-capture-prewarm",
-requestStartRecording: "request-start-recording",
-setCaptureAreaPending: "set-capture-area-pending",
-targetUnderCursor: "target-under-cursor",
-uploadProgressEvent: "upload-progress-event"
-})
-
-/** user-defined constants **/
-
-
-
-/** user-defined types **/
-
-export type Annotation = { id: string; type: AnnotationType; x: number; y: number; width: number; height: number; strokeColor: string; strokeWidth: number; fillColor: string; opacity: number; rotation: number; text: string | null; maskType?: MaskType | null; maskLevel?: number | null }
-export type AnnotationType = "arrow" | "circle" | "rectangle" | "text" | "mask"
-export type AppTheme = "system" | "light" | "dark"
-export type AspectRatio = "wide" | "vertical" | "square" | "classic" | "tall"
-export type Audio = { duration: number; sample_rate: number; channels: number; start_time: number }
-export type AudioConfiguration = { mute: boolean; improve: boolean; micVolumeDb?: number; micStereoMode?: StereoMode; systemVolumeDb?: number }
-export type AudioInputLevelChange = number
-export type AudioMeta = { path: string; start_time?: number | null }
-export type AuthSecret = { api_key: string } | { token: string; expires: number }
-export type AuthStore = { secret: AuthSecret; user_id: string | null; plan: Plan | null; intercom_hash: string | null; organizations?: Organization[] }
-export type BackgroundConfiguration = { source: BackgroundSource; blur: number; padding: number; rounding: number; roundingType?: CornerStyle; inset: number; crop: Crop | null; shadow?: number; advancedShadow?: ShadowConfiguration | null; border?: BorderConfiguration | null }
-export type BackgroundSource = { type: "wallpaper"; path: string | null } | { type: "image"; path: string | null } | { type: "color"; value: [number, number, number]; alpha?: number } | { type: "gradient"; from: [number, number, number]; to: [number, number, number]; angle?: number }
-export type BorderConfiguration = { enabled: boolean; width: number; color: [number, number, number]; opacity: number }
-export type Camera = { hide: boolean; mirror: boolean; position: CameraPosition; size: number; zoomSize: number | null; rounding?: number; shadow?: number; advancedShadow?: ShadowConfiguration | null; shape?: CameraShape; roundingType?: CornerStyle }
-export type CameraInfo = { device_id: string; model_id: ModelIDType | null; display_name: string }
-export type CameraPosition = { x: CameraXPosition; y: CameraYPosition }
-export type CameraPreviewShape = "round" | "square" | "full"
-export type CameraPreviewState = { size: number; shape: CameraPreviewShape; mirrored: boolean }
-export type CameraShape = "square" | "source"
-export type CameraXPosition = "left" | "center" | "right"
-export type CameraYPosition = "top" | "bottom"
-export type CaptionData = { segments: CaptionSegment[]; settings: CaptionSettings | null }
-export type CaptionSegment = { id: string; start: number; end: number; text: string; words?: CaptionWord[] }
-export type CaptionSettings = { enabled: boolean; font: string; size: number; color: string; backgroundColor: string; backgroundOpacity: number; position?: string; italic: boolean; fontWeight?: number; outline: boolean; outlineColor: string; exportWithSubtitles: boolean; highlightColor?: string; fadeDuration?: number; lingerDuration?: number; wordTransitionDuration?: number }
-export type CaptionWord = { text: string; start: number; end: number }
-export type CaptionsData = { segments: CaptionSegment[]; settings: CaptionSettings }
-export type CaptureDisplay = { id: DisplayId; name: string; refresh_rate: number }
-export type CaptureDisplayWithThumbnail = { id: DisplayId; name: string; refresh_rate: number; thumbnail: string | null }
-export type CaptureWindow = { id: WindowId; owner_name: string; name: string; bounds: LogicalBounds; refresh_rate: number; bundle_identifier: string | null }
-export type CaptureWindowWithThumbnail = { id: WindowId; owner_name: string; name: string; bounds: LogicalBounds; refresh_rate: number; thumbnail: string | null; app_icon: string | null; bundle_identifier: string | null }
-export type ClipConfiguration = { index: number; offsets: ClipOffsets }
-export type ClipOffsets = { camera?: number; mic?: number; system_audio?: number }
-export type CommercialLicense = { licenseKey: string; expiryDate: number | null; refresh: number; activatedOn: number }
-export type CornerStyle = "squircle" | "rounded"
-export type Crop = { position: XY<number>; size: XY<number> }
-export type CurrentRecording = { target: CurrentRecordingTarget; mode: RecordingMode; status: RecordingStatus }
-export type CurrentRecordingChanged = null
-export type CurrentRecordingTarget = { window: { id: WindowId; bounds: LogicalBounds | null } } | { screen: { id: DisplayId } } | { area: { screen: DisplayId; bounds: LogicalBounds } }
-export type CursorAnimationStyle = "slow" | "mellow" | "custom"
-export type CursorConfiguration = { hide?: boolean; hideWhenIdle?: boolean; hideWhenIdleDelay?: number; size: number; type: CursorType; animationStyle: CursorAnimationStyle; tension: number; mass: number; friction: number; raw?: boolean; motionBlur?: number; useSvg?: boolean }
-export type CursorMeta = { imagePath: string; hotspot: XY<number>; shape?: string | null }
-export type CursorType = "auto" | "pointer" | "circle"
-export type Cursors = { [key in string]: string } | { [key in string]: CursorMeta }
-export type DeviceOrModelID = { DeviceID: string } | { ModelID: ModelIDType }
-export type DisplayId = string
-export type DisplayInformation = { name: string | null; physical_size: PhysicalSize | null; logical_size: LogicalSize | null; refresh_rate: string }
-export type DownloadProgress = { progress: number; message: string }
-export type EditorStateChanged = { playhead_position: number }
-export type ExportCompression = "Minimal" | "Social" | "Web" | "Potato"
-export type ExportEstimates = { duration_seconds: number; estimated_time_seconds: number; estimated_size_mb: number }
-export type ExportPreviewResult = { jpeg_base64: string; estimated_size_mb: number; actual_width: number; actual_height: number; frame_render_time_ms: number; total_frames: number }
-export type ExportPreviewSettings = { fps: number; resolution_base: XY<number>; compression_bpp: number }
-export type ExportSettings = ({ format: "Mp4" } & Mp4ExportSettings) | ({ format: "Gif" } & GifExportSettings)
-export 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 GifExportSettings = { fps: number; resolution_base: XY<number>; quality: GifQuality | null }
-export type GifQuality = {
-/**
- * Encoding quality from 1-100 (default: 90)
- */
-quality: number | null;
-/**
- * Whether to prioritize speed over quality (default: false)
- */
-fast: boolean | null }
-export type HapticPattern = "alignment" | "levelChange" | "generic"
-export type HapticPerformanceTime = "default" | "now" | "drawCompleted"
-export type Hotkey = { code: string; meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }
-export type HotkeyAction = "startStudioRecording" | "startInstantRecording" | "stopRecording" | "restartRecording" | "cycleRecordingMode" | "openRecordingPicker" | "openRecordingPickerDisplay" | "openRecordingPickerWindow" | "openRecordingPickerArea" | "other"
-export type HotkeysConfiguration = { show: boolean }
-export type HotkeysStore = { hotkeys: { [key in HotkeyAction]: Hotkey } }
-export type IncompleteRecordingInfo = { projectPath: string; prettyName: string; segmentCount: number; estimatedDurationSecs: number }
-export type InstantRecordingMeta = { recording: boolean } | { error: string } | { fps: number; sample_rate: number | null }
-export type JsonValue<T> = [T]
-export type LogicalBounds = { position: LogicalPosition; size: LogicalSize }
-export type LogicalPosition = { x: number; y: number }
-export type LogicalSize = { width: number; height: number }
-export type MacOSVersionInfo = { displayName: string }
-export type MainWindowRecordingStartBehaviour = "close" | "minimise"
-export type MaskKeyframes = { position?: MaskVectorKeyframe[]; size?: MaskVectorKeyframe[]; intensity?: MaskScalarKeyframe[] }
-export type MaskKind = "sensitive" | "highlight"
-export type MaskScalarKeyframe = { time: number; value: number }
-export type MaskSegment = { start: number; end: number; enabled?: boolean; maskType: MaskKind; center: XY<number>; size: XY<number>; feather?: number; opacity?: number; pixelation?: number; darkness?: number; fadeDuration?: number; keyframes?: MaskKeyframes }
-export type MaskType = "blur" | "pixelate"
-export type MaskVectorKeyframe = { time: number; x: number; y: number }
-export type ModelIDType = string
-export type Mp4ExportSettings = { fps: number; resolution_base: XY<number>; compression: ExportCompression }
-export type MultipleSegment = { display: VideoMeta; camera?: VideoMeta | null; mic?: AudioMeta | null; system_audio?: AudioMeta | null; cursor?: string | null }
-export type MultipleSegments = { segments: MultipleSegment[]; cursors: Cursors; status?: StudioRecordingStatus | null }
-export type NewNotification = { title: string; body: string; is_error: boolean }
-export type NewScreenshotAdded = { path: string }
-export type NewStudioRecordingAdded = { path: string }
-export type OSPermission = "screenRecording" | "camera" | "microphone" | "accessibility"
-export type OSPermissionStatus = "notNeeded" | "empty" | "granted" | "denied"
-export type OSPermissionsCheck = { screenRecording: OSPermissionStatus; microphone: OSPermissionStatus; camera: OSPermissionStatus; accessibility: OSPermissionStatus }
-export type OnEscapePress = null
-export type Organization = { id: string; name: string; ownerId: string }
-export type PhysicalSize = { width: number; height: number }
-export type Plan = { upgraded: boolean; manual: boolean; last_checked: number }
-export type Platform = "MacOS" | "Windows"
-export type PostDeletionBehaviour = "doNothing" | "reopenRecordingWindow"
-export type PostStudioRecordingBehaviour = "openEditor" | "showOverlay"
-export type Preset = { name: string; config: ProjectConfiguration }
-export type PresetsStore = { presets: Preset[]; default: number | null }
-export type ProjectConfiguration = { aspectRatio: AspectRatio | null; background: BackgroundConfiguration; camera: Camera; audio: AudioConfiguration; cursor: CursorConfiguration; hotkeys: HotkeysConfiguration; timeline?: TimelineConfiguration | null; captions?: CaptionsData | null; clips?: ClipConfiguration[]; annotations?: Annotation[] }
-export type ProjectRecordingsMeta = { segments: SegmentRecordings[] }
-export type RecordingAction = "Started" | "InvalidAuthentication" | "UpgradeRequired"
-export type RecordingDeleted = { path: string }
-export type RecordingEvent = { variant: "Countdown"; value: number } | { variant: "Started" } | { variant: "Stopped" } | { variant: "Failed"; error: string } | { variant: "InputLost"; input: RecordingInputKind } | { variant: "InputRestored"; input: RecordingInputKind }
-export type RecordingInputKind = "microphone" | "camera"
-export type RecordingMeta = (StudioRecordingMeta | InstantRecordingMeta) & { platform?: Platform | null; pretty_name: string; sharing?: SharingMeta | null; upload?: UploadMeta | null }
-export type RecordingMetaWithMetadata = ((StudioRecordingMeta | InstantRecordingMeta) & { platform?: Platform | null; pretty_name: string; sharing?: SharingMeta | null; upload?: UploadMeta | null }) & { mode: RecordingMode; status: StudioRecordingStatus }
-export type RecordingMode = "studio" | "instant" | "screenshot"
-export type RecordingOptionsChanged = null
-export type RecordingSettingsStore = { target: ScreenCaptureTarget | null; micName: string | null; cameraId: DeviceOrModelID | null; mode: RecordingMode | null; systemAudio: boolean; organizationId: string | null }
-export type RecordingStarted = null
-export type RecordingStatus = "pending" | "recording"
-export type RecordingStopped = null
-export type RecordingTargetMode = "display" | "window" | "area"
-export type RenderFrameEvent = { frame_number: number; fps: number; resolution_base: XY<number> }
-export type RequestOpenRecordingPicker = { target_mode: RecordingTargetMode | null }
-export type RequestOpenSettings = { page: string }
-export type RequestScreenCapturePrewarm = { force?: boolean }
-export type RequestStartRecording = { mode: RecordingMode }
-export type S3UploadMeta = { id: string }
-export type SceneMode = "default" | "cameraOnly" | "hideCamera"
-export type SceneSegment = { start: number; end: number; mode?: SceneMode }
-export type ScreenCaptureTarget = { variant: "window"; id: WindowId } | { variant: "display"; id: DisplayId } | { variant: "area"; screen: DisplayId; bounds: LogicalBounds }
-export type SegmentRecordings = { display: Video; camera: Video | null; mic: Audio | null; system_audio: Audio | null }
-export type SerializedEditorInstance = { framesSocketUrl: string; recordingDuration: number; savedProjectConfig: ProjectConfiguration; recordings: ProjectRecordingsMeta; path: string }
-export type SerializedScreenshotEditorInstance = { framesSocketUrl: string; path: string; config: ProjectConfiguration | null; prettyName: string }
-export type SetCaptureAreaPending = boolean
-export type ShadowConfiguration = { size: number; opacity: number; blur: number }
-export type SharingMeta = { id: string; link: string }
-export type ShowCapWindow = "Setup" | { Main: { init_target_mode: RecordingTargetMode | null } } | { Settings: { page: string | null } } | { Editor: { project_path: string } } | "RecordingsOverlay" | { WindowCaptureOccluder: { screen_id: DisplayId } } | { TargetSelectOverlay: { display_id: DisplayId } } | { CaptureArea: { screen_id: DisplayId } } | "Camera" | { InProgressRecording: { countdown: number | null } } | "Upgrade" | "ModeSelect" | { ScreenshotEditor: { path: string } }
-export type SingleSegment = { display: VideoMeta; camera?: VideoMeta | null; audio?: AudioMeta | null; cursor?: string | null }
-export type StartRecordingInputs = { capture_target: ScreenCaptureTarget; capture_system_audio?: boolean; mode: RecordingMode; organization_id?: string | null }
-export type StereoMode = "stereo" | "monoL" | "monoR"
-export type StudioRecordingMeta = { segment: SingleSegment } | { inner: MultipleSegments }
-export type StudioRecordingStatus = { status: "InProgress" } | { status: "NeedsRemux" } | { status: "Failed"; error: string } | { status: "Complete" }
-export type SystemDiagnostics = { macosVersion: MacOSVersionInfo | null; availableEncoders: string[]; screenCaptureSupported: boolean }
-export type TargetUnderCursor = { display_id: DisplayId | null; window: WindowUnderCursor | null }
-export type TextSegment = { start: number; end: number; enabled?: boolean; content?: string; center?: XY<number>; size?: XY<number>; fontFamily?: string; fontSize?: number; fontWeight?: number; italic?: boolean; color?: string; fadeDuration?: number }
-export type TimelineConfiguration = { segments: TimelineSegment[]; zoomSegments: ZoomSegment[]; sceneSegments?: SceneSegment[]; maskSegments?: MaskSegment[]; textSegments?: TextSegment[] }
-export type TimelineSegment = { recordingSegment?: number; timescale: number; start: number; end: number }
-export type UploadMeta = { state: "MultipartUpload"; video_id: string; file_path: string; pre_created_video: VideoUploadInfo; recording_dir: string } | { state: "SinglePartUpload"; video_id: string; recording_dir: string; file_path: string; screenshot_path: string } | { state: "Failed"; error: string } | { state: "Complete" }
-export type UploadMode = { Initial: { pre_created_video: VideoUploadInfo | null } } | "Reupload"
-export type UploadProgress = { progress: number }
-export type UploadProgressEvent = { video_id: string; uploaded: string; total: string }
-export type UploadResult = { Success: string } | "NotAuthenticated" | "PlanCheckFailed" | "UpgradeRequired"
-export type Video = { duration: number; width: number; height: number; fps: number; start_time: number }
-export type VideoMeta = { path: string; fps?: number; start_time?: number | null }
-export type VideoRecordingMetadata = { duration: number; size: number }
-export type VideoUploadInfo = { id: string; link: string; config: S3UploadMeta }
-export type WindowExclusion = { bundleIdentifier?: string | null; ownerName?: string | null; windowTitle?: string | null }
-export type WindowId = string
-export type WindowUnderCursor = { id: WindowId; app_name: string; bounds: LogicalBounds }
-export type XY<T> = { x: T; y: T }
-export type ZoomMode = "auto" | { manual: { x: number; y: number } }
-export type ZoomSegment = { start: number; end: number; amount: number; mode: ZoomMode }
-
-/** tauri-specta globals **/
-
-import {
- invoke as TAURI_INVOKE,
- Channel as TAURI_CHANNEL,
-} from "@tauri-apps/api/core";
-import * as TAURI_API_EVENT from "@tauri-apps/api/event";
-import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
-
-type __EventObj__<T> = {
- listen: (
- cb: TAURI_API_EVENT.EventCallback<T>,
- ) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
- once: (
- cb: TAURI_API_EVENT.EventCallback<T>,
- ) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
- emit: null extends T
- ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
- : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
-};
-
-export type Result<T, E> =
- | { status: "ok"; data: T }
- | { status: "error"; error: E };
-
-function __makeEvents__<T extends Record<string, any>>(
- mappings: Record<keyof T, string>,
-) {
- return new Proxy(
- {} as unknown as {
- [K in keyof T]: __EventObj__<T[K]> & {
- (handle: __WebviewWindow__): __EventObj__<T[K]>;
- };
- },
- {
- get: (_, event) => {
- const name = mappings[event as keyof T];
-
- return new Proxy((() => {}) as any, {
- apply: (_, __, [window]: [__WebviewWindow__]) => ({
- listen: (arg: any) => window.listen(name, arg),
- once: (arg: any) => window.once(name, arg),
- emit: (arg: any) => window.emit(name, arg),
- }),
- get: (_, command: keyof __EventObj__<any>) => {
- switch (command) {
- case "listen":
- return (arg: any) => TAURI_API_EVENT.listen(name, arg);
- case "once":
- return (arg: any) => TAURI_API_EVENT.once(name, arg);
- case "emit":
- return (arg: any) => TAURI_API_EVENT.emit(name, arg);
- }
- },
- });
- },
- },
- );
-}
diff --git a/crates/enc-ffmpeg/Cargo.toml b/crates/enc-ffmpeg/Cargo.toml
index 0c010bcee..9036dc640 100644
--- a/crates/enc-ffmpeg/Cargo.toml
+++ b/crates/enc-ffmpeg/Cargo.toml
@@ -9,6 +9,7 @@ cap-media-info = { path = "../media-info" }
ffmpeg.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
+sysinfo.workspace = true
thiserror.workspace = true
tracing.workspace = true
workspace-hack = { version = "0.1", path = "../workspace-hack" }
diff --git a/crates/enc-ffmpeg/src/lib.rs b/crates/enc-ffmpeg/src/lib.rs
index 2dd64f560..2d72a7523 100644
--- a/crates/enc-ffmpeg/src/lib.rs
+++ b/crates/enc-ffmpeg/src/lib.rs
@@ -13,3 +13,6 @@ pub mod remux;
pub mod segmented_audio {
pub use crate::mux::segmented_audio::*;
}
+pub mod segmented_stream {
+ pub use crate::mux::segmented_stream::*;
+}
diff --git a/crates/enc-ffmpeg/src/mux/segmented_stream.rs b/crates/enc-ffmpeg/src/mux/segmented_stream.rs
index 6b841f79f..e1e257c96 100644
--- a/crates/enc-ffmpeg/src/mux/segmented_stream.rs
+++ b/crates/enc-ffmpeg/src/mux/segmented_stream.rs
@@ -5,12 +5,26 @@ use std::{
ffi::CString,
io::Write,
path::{Path, PathBuf},
+ sync::Arc,
time::Duration,
};
+use sysinfo::Disks;
use crate::video::h264::{H264Encoder, H264EncoderBuilder, H264EncoderError, H264Preset};
const INIT_SEGMENT_NAME: &str = "init.mp4";
+const DISK_SPACE_WARNING_THRESHOLD_MB: u64 = 500;
+const DISK_SPACE_CRITICAL_THRESHOLD_MB: u64 = 100;
+
+#[derive(Debug, Clone)]
+pub struct DiskSpaceWarning {
+ pub available_mb: u64,
+ pub threshold_mb: u64,
+ pub path: String,
+ pub is_critical: bool,
+}
+
+pub type DiskSpaceCallback = Arc<dyn Fn(DiskSpaceWarning) + Send + Sync>;
fn atomic_write_json<T: Serialize>(path: &Path, data: &T) -> std::io::Result<()> {
let temp_path = path.with_extension("json.tmp");
@@ -59,6 +73,10 @@ pub struct SegmentedVideoEncoder {
completed_segments: Vec<VideoSegmentInfo>,
codec_info: CodecInfo,
+
+ disk_space_callback: Option<DiskSpaceCallback>,
+ disk_space_warned: bool,
+ disk_space_critical_warned: bool,
}
#[derive(Debug, Clone)]
@@ -125,6 +143,8 @@ pub enum QueueFrameError {
Init(#[from] InitError),
#[error("Encode: {0}")]
Encode(#[from] crate::video::h264::QueueFrameError),
+ #[error("Init segment validation failed: {0}")]
+ InitSegmentInvalid(String),
}
#[derive(thiserror::Error, Debug)]
@@ -237,6 +257,9 @@ impl SegmentedVideoEncoder {
frames_in_segment: 0,
completed_segments: Vec::new(),
codec_info,
+ disk_space_callback: None,
+ disk_space_warned: false,
+ disk_space_critical_warned: false,
};
instance.write_in_progress_manifest();
@@ -244,6 +267,59 @@ impl SegmentedVideoEncoder {
Ok(instance)
}
+ pub fn set_disk_space_callback(&mut self, callback: DiskSpaceCallback) {
+ self.disk_space_callback = Some(callback);
+ }
+
+ fn check_disk_space(&mut self) {
+ let Some(callback) = &self.disk_space_callback else {
+ return;
+ };
+
+ let disks = Disks::new_with_refreshed_list();
+
+ let matching_disk = disks.iter().find(|disk| {
+ let mount_point = disk.mount_point();
+ self.base_path.starts_with(mount_point)
+ });
+
+ let Some(disk) = matching_disk else {
+ tracing::debug!("Could not find disk for path {}", self.base_path.display());
+ return;
+ };
+
+ let available_bytes = disk.available_space();
+ let available_mb = available_bytes / 1024 / 1024;
+
+ if available_mb < DISK_SPACE_CRITICAL_THRESHOLD_MB && !self.disk_space_critical_warned {
+ tracing::error!(
+ available_mb,
+ path = %self.base_path.display(),
+ "CRITICAL: Disk space critically low! Recording may fail."
+ );
+ self.disk_space_critical_warned = true;
+ callback(DiskSpaceWarning {
+ available_mb,
+ threshold_mb: DISK_SPACE_CRITICAL_THRESHOLD_MB,
+ path: self.base_path.display().to_string(),
+ is_critical: true,
+ });
+ } else if available_mb < DISK_SPACE_WARNING_THRESHOLD_MB && !self.disk_space_warned {
+ tracing::warn!(
+ available_mb,
+ path = %self.base_path.display(),
+ "Disk space running low. Consider freeing up space."
+ );
+ self.disk_space_warned = true;
+ callback(DiskSpaceWarning {
+ available_mb,
+ threshold_mb: DISK_SPACE_WARNING_THRESHOLD_MB,
+ path: self.base_path.display().to_string(),
+ is_critical: false,
+ });
+ }
+ }
+
pub fn queue_frame(
&mut self,
frame: frame::Video,
@@ -317,12 +393,13 @@ impl SegmentedVideoEncoder {
self.segment_start_time = Some(timestamp);
self.frames_in_segment = 0;
- if let Err(e) = self.validate_init_segment() {
- tracing::error!("{e}");
- }
+ self.validate_init_segment()
+ .map_err(QueueFrameError::InitSegmentInvalid)?;
self.write_manifest();
self.write_in_progress_manifest();
+
+ self.check_disk_space();
}
Ok(())
diff --git a/crates/recording/src/output_pipeline/macos_fragmented_m4s.rs b/crates/recording/src/output_pipeline/macos_fragmented_m4s.rs
index bbca09774..8dcf21a57 100644
--- a/crates/recording/src/output_pipeline/macos_fragmented_m4s.rs
+++ b/crates/recording/src/output_pipeline/macos_fragmented_m4s.rs
@@ -4,7 +4,9 @@ use crate::{
};
use anyhow::{Context, anyhow};
use cap_enc_ffmpeg::h264::{H264EncoderBuilder, H264Preset};
-use cap_enc_ffmpeg::segmented_stream::{SegmentedVideoEncoder, SegmentedVideoEncoderConfig};
+use cap_enc_ffmpeg::segmented_stream::{
+ DiskSpaceCallback, SegmentedVideoEncoder, SegmentedVideoEncoderConfig,
+};
use cap_media_info::{AudioInfo, VideoInfo};
use std::{
path::PathBuf,
@@ -102,6 +104,7 @@ pub struct MacOSFragmentedM4SMuxer {
pause: SharedPauseState,
frame_drops: FrameDropTracker,
started: bool,
+ disk_space_callback: Option<DiskSpaceCallback>,
}
pub struct MacOSFragmentedM4SMuxerConfig {
@@ -109,6 +112,7 @@ pub struct MacOSFragmentedM4SMuxerConfig {
pub preset: H264Preset,
pub output_size: Option<(u32, u32)>,
pub shared_pause_state: Option<SharedPauseState>,
+ pub disk_space_callback: Option<DiskSpaceCallback>,
}
impl Default for MacOSFragmentedM4SMuxerConfig {
@@ -118,6 +122,7 @@ impl Default for MacOSFragmentedM4SMuxerConfig {
preset: H264Preset::Ultrafast,
output_size: None,
shared_pause_state: None,
+ disk_space_callback: None,
}
}
}
@@ -156,6 +161,7 @@ impl Muxer for MacOSFragmentedM4SMuxer {
pause,
frame_drops: FrameDropTracker::new(),
started: false,
+ disk_space_callback: config.disk_space_callback,
})
}
@@ -238,8 +244,11 @@ impl MacOSFragmentedM4SMuxer {
output_size: self.output_size,
};
- let encoder =
+ let mut encoder =
SegmentedVideoEncoder::init(self.base_path.clone(), self.video_config, encoder_config)?;
+ if let Some(callback) = &self.disk_space_callback {
+ encoder.set_disk_space_callback(callback.clone());
+ }
let encoder = Arc::new(Mutex::new(encoder));
let encoder_clone = encoder.clone();
let video_config = self.video_config;
@@ -584,6 +593,7 @@ pub struct MacOSFragmentedM4SCameraMuxer {
pause: SharedPauseState,
frame_drops: FrameDropTracker,
started: bool,
+ disk_space_callback: Option<DiskSpaceCallback>,
}
pub struct MacOSFragmentedM4SCameraMuxerConfig {
@@ -591,6 +601,7 @@ pub struct MacOSFragmentedM4SCameraMuxerConfig {
pub preset: H264Preset,
pub output_size: Option<(u32, u32)>,
pub shared_pause_state: Option<SharedPauseState>,
+ pub disk_space_callback: Option<DiskSpaceCallback>,
}
impl Default for MacOSFragmentedM4SCameraMuxerConfig {
@@ -600,6 +611,7 @@ impl Default for MacOSFragmentedM4SCameraMuxerConfig {
preset: H264Preset::Ultrafast,
output_size: None,
shared_pause_state: None,
+ disk_space_callback: None,
}
}
}
@@ -639,6 +651,7 @@ impl Muxer for MacOSFragmentedM4SCameraMuxer {
pause,
frame_drops: FrameDropTracker::new(),
started: false,
+ disk_space_callback: config.disk_space_callback,
})
}
@@ -721,8 +734,11 @@ impl MacOSFragmentedM4SCameraMuxer {
output_size: self.output_size,
};
- let encoder =
+ let mut encoder =
SegmentedVideoEncoder::init(self.base_path.clone(), self.video_config, encoder_config)?;
+ if let Some(callback) = &self.disk_space_callback {
+ encoder.set_disk_space_callback(callback.clone());
+ }
let encoder = Arc::new(Mutex::new(encoder));
let encoder_clone = encoder.clone();
let video_config = self.video_config;
diff --git a/crates/recording/src/output_pipeline/win_fragmented_m4s.rs b/crates/recording/src/output_pipeline/win_fragmented_m4s.rs
index a15d829b4..4afc996e1 100644
--- a/crates/recording/src/output_pipeline/win_fragmented_m4s.rs
+++ b/crates/recording/src/output_pipeline/win_fragmented_m4s.rs
@@ -5,7 +5,9 @@ use crate::{
};
use anyhow::{Context, anyhow};
use cap_enc_ffmpeg::h264::{H264EncoderBuilder, H264Preset};
-use cap_enc_ffmpeg::segmented_stream::{SegmentedVideoEncoder, SegmentedVideoEncoderConfig};
+use cap_enc_ffmpeg::segmented_stream::{
+ DiskSpaceCallback, SegmentedVideoEncoder, SegmentedVideoEncoderConfig,
+};
use cap_media_info::{AudioInfo, VideoInfo};
use scap_ffmpeg::AsFFmpeg;
use std::{
@@ -104,6 +106,7 @@ pub struct WindowsFragmentedM4SMuxer {
pause: SharedPauseState,
frame_drops: FrameDropTracker,
started: bool,
+ disk_space_callback: Option<DiskSpaceCallback>,
}
pub struct WindowsFragmentedM4SMuxerConfig {
@@ -111,6 +114,7 @@ pub struct WindowsFragmentedM4SMuxerConfig {
pub preset: H264Preset,
pub output_size: Option<(u32, u32)>,
pub shared_pause_state: Option<SharedPauseState>,
+ pub disk_space_callback: Option<DiskSpaceCallback>,
}
impl Default for WindowsFragmentedM4SMuxerConfig {
@@ -120,6 +124,7 @@ impl Default for WindowsFragmentedM4SMuxerConfig {
preset: H264Preset::Ultrafast,
output_size: None,
shared_pause_state: None,
+ disk_space_callback: None,
}
}
}
@@ -158,6 +163,7 @@ impl Muxer for WindowsFragmentedM4SMuxer {
pause,
frame_drops: FrameDropTracker::new(),
started: false,
+ disk_space_callback: config.disk_space_callback,
})
}
@@ -240,8 +246,11 @@ impl WindowsFragmentedM4SMuxer {
output_size: self.output_size,
};
- let encoder =
+ let mut encoder =
SegmentedVideoEncoder::init(self.base_path.clone(), self.video_config, encoder_config)?;
+ if let Some(callback) = &self.disk_space_callback {
+ encoder.set_disk_space_callback(callback.clone());
+ }
let encoder = Arc::new(Mutex::new(encoder));
let encoder_clone = encoder.clone();
@@ -414,6 +423,7 @@ pub struct WindowsFragmentedM4SCameraMuxer {
pause: SharedPauseState,
frame_drops: FrameDropTracker,
started: bool,
+ disk_space_callback: Option<DiskSpaceCallback>,
}
pub struct WindowsFragmentedM4SCameraMuxerConfig {
@@ -421,6 +431,7 @@ pub struct WindowsFragmentedM4SCameraMuxerConfig {
pub preset: H264Preset,
pub output_size: Option<(u32, u32)>,
pub shared_pause_state: Option<SharedPauseState>,
+ pub disk_space_callback: Option<DiskSpaceCallback>,
}
impl Default for WindowsFragmentedM4SCameraMuxerConfig {
@@ -430,6 +441,7 @@ impl Default for WindowsFragmentedM4SCameraMuxerConfig {
preset: H264Preset::Ultrafast,
output_size: None,
shared_pause_state: None,
+ disk_space_callback: None,
}
}
}
@@ -469,6 +481,7 @@ impl Muxer for WindowsFragmentedM4SCameraMuxer {
pause,
frame_drops: FrameDropTracker::new(),
started: false,
+ disk_space_callback: config.disk_space_callback,
})
}
@@ -551,8 +564,11 @@ impl WindowsFragmentedM4SCameraMuxer {
output_size: self.output_size,
};
- let encoder =
+ let mut encoder =
SegmentedVideoEncoder::init(self.base_path.clone(), self.video_config, encoder_config)?;
+ if let Some(callback) = &self.disk_space_callback {
+ encoder.set_disk_space_callback(callback.clone());
+ }
let encoder = Arc::new(Mutex::new(encoder));
let encoder_clone = encoder.clone();