Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Merge branch 'main' into feat/add-export-metadata-display

David Anyatonwu3ce758ea3324
diff --cc apps/desktop/src-tauri/src/lib.rs
index 7dd8a9849,d0cb1448e..a67d28aa0
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@@ -910,29 -940,6 +940,30 @@@ async fn copy_video_to_clipboard
Ok(())
}
++
+#[derive(Serialize, Deserialize, specta::Type)]
+pub struct VideoRecordingMetadata {
+ duration: f64,
+ size: f64,
+}
+
+// Helper function to estimate rendered file size based on duration and quality
+fn estimate_rendered_size(duration: f64) -> f64 {
+ // Use actual encoder bitrates:
+ // - Video: 8-10 Mbps (from H264 encoder implementations)
+ // - Audio: 128 Kbps (fixed in all encoders)
+ #[cfg(target_os = "macos")]
+ let video_bitrate = 10_000_000.0; // 10 Mbps (AVAssetWriter)
+ #[cfg(not(target_os = "macos"))]
+ let video_bitrate = 8_000_000.0; // 8 Mbps (libx264)
+
+ let audio_bitrate = 128_000.0; // 128 Kbps (fixed in encoders)
+
+ // Total data = (video_bitrate + audio_bitrate) * duration / 8 bits per byte
+ // Convert to MB by dividing by (1024 * 1024)
+ ((video_bitrate + audio_bitrate) * duration) / (8.0 * 1024.0 * 1024.0)
+}
+
#[tauri::command]
#[specta::specta]
async fn get_video_metadata(