Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fmt
Richie McIlroyb3f2551131a8
diff --git a/apps/desktop/src-tauri/src/import.rs b/apps/desktop/src-tauri/src/import.rsindex f2e963258..f23bf7787 100644--- a/apps/desktop/src-tauri/src/import.rs+++ b/apps/desktop/src-tauri/src/import.rs@@ -73,6 +73,10 @@ fn emit_progress(.emit(app);}+fn check_project_exists(project_path: &Path) -> bool {+ project_path.exists() && project_path.join("recording-meta.json").exists()+}+fn generate_project_name(source_path: &Path) -> String {let stem = source_path.file_stem()@@ -153,6 +157,7 @@ fn transcode_video(output_path: &Path,audio_output_path: Option<&Path>,project_path_str: &str,+ project_path: &Path,) -> Result<(u32, Option<u32>), ImportError> {use std::time::Duration as StdDuration;@@ -165,7 +170,7 @@ fn transcode_video(let output_width = ensure_even(video_info.width);let output_height = ensure_even(video_info.height);let fps = video_info.frame_rate.0 as u32 / video_info.frame_rate.1.max(1) as u32;- let fps = fps.max(1).min(120);+ let fps = fps.clamp(1, 120);let duration = get_media_duration(source_path);let total_frames = duration@@ -224,7 +229,7 @@ fn transcode_video(})?;audio_encoder = Some(Box::new(- OpusEncoder::init(audio_info.clone(), &mut audio_out)+ OpusEncoder::init(*audio_info, &mut audio_out).map_err(|e| ImportError::EncoderFailed(e.to_string()))?,));audio_out.write_header().map_err(|e| {@@ -305,6 +310,12 @@ fn transcode_video(let progress = (frames_processed as f64 / total_frames as f64).min(0.99);if progress - last_progress >= 0.01 {last_progress = progress;++ if !check_project_exists(project_path) {+ info!("Import cancelled: project directory was deleted");+ return Err(ImportError::TranscodeFailed("Import cancelled".to_string()));+ }+emit_progress(app,project_path_str,@@ -512,6 +523,12 @@ pub async fn start_video_import(app: AppHandle, source_path: PathBuf) -> Result<let source_path_clone = source_path.clone();let output_path_clone = output_video_path.clone();let audio_path_clone = output_audio_path.clone();+ let project_path_clone = project_path.clone();++ if !check_project_exists(&project_path) {+ info!("Import aborted before start: project directory missing");+ return;+ }let result = tokio::task::spawn_blocking(move || {transcode_video(@@ -520,6 +537,7 @@ pub async fn start_video_import(app: AppHandle, source_path: PathBuf) -> Result<&output_path_clone,Some(&audio_path_clone),&project_path_str_clone,+ &project_path_clone,)}).await;diff --git a/crates/export/tests/long_video_export.rs b/crates/export/tests/long_video_export.rsindex 5f8e0c561..2d75b5ff2 100644--- a/crates/export/tests/long_video_export.rs+++ b/crates/export/tests/long_video_export.rs@@ -28,7 +28,7 @@ fn check_ffmpeg_available() -> bool {.unwrap_or(false)}-fn generate_test_video(output_path: &PathBuf, duration_secs: u32) -> Result<(), String> {+fn generate_test_video(output_path: &Path, duration_secs: u32) -> Result<(), String> {let status = Command::new("ffmpeg").args(["-y",@@ -64,7 +64,7 @@ fn generate_test_video(output_path: &PathBuf, duration_secs: u32) -> Result<(),Ok(())}-fn create_cap_project(project_dir: &PathBuf, duration_secs: u32) -> Result<(), String> {+fn create_cap_project(project_dir: &Path, duration_secs: u32) -> Result<(), String> {let content_dir = project_dir.join("content");fs::create_dir_all(&content_dir).map_err(|e| format!("Failed to create content dir: {e}"))?;diff --git a/crates/rendering/src/layers/captions.rs b/crates/rendering/src/layers/captions.rsindex 9f2c3f4fb..01c9b30e5 100644--- a/crates/rendering/src/layers/captions.rs+++ b/crates/rendering/src/layers/captions.rs@@ -5,7 +5,7 @@ use glyphon::{Attrs, Buffer, Cache, Color, Family, FontSystem, Metrics, Resolution, Shaping, SwashCache,TextArea, TextAtlas, TextBounds, TextRenderer, Viewport, Weight,};-use log::{debug, warn};+use log::warn;use wgpu::{Device, Queue, include_wgsl, util::DeviceExt};use crate::{DecodedSegmentFrames, ProjectUniforms, RenderVideoConstants, parse_color_component};@@ -380,7 +380,6 @@ impl CaptionsLayer {}pub fn update_caption(&mut self, text: Option<String>, start: f32, end: f32) {- debug!("Updating caption - Text: {text:?}, Start: {start}, End: {end}");self.current_text = text;self.current_segment_start = start;self.current_segment_end = end;diff --git a/crates/rendering/src/project_recordings.rs b/crates/rendering/src/project_recordings.rsindex 7186fb98b..e0b9985b3 100644--- a/crates/rendering/src/project_recordings.rs+++ b/crates/rendering/src/project_recordings.rs@@ -26,12 +26,15 @@ impl Video {.best(ffmpeg::media::Type::Video).ok_or_else(|| "No video stream found".to_string())?;- let params = stream.parameters();+ let decoder_ctx = ffmpeg::codec::Context::from_parameters(stream.parameters())+ .map_err(|e| format!("Failed to create decoder context: {e}"))?;+ let decoder = decoder_ctx+ .decoder()+ .video()+ .map_err(|e| format!("Failed to get video decoder: {e}"))?;- let (width, height) = unsafe {- let ptr = params.as_ptr();- ((*ptr).width as u32, (*ptr).height as u32)- };+ let width = decoder.width();+ let height = decoder.height();if width == 0 || height == 0 {return Err("Invalid video dimensions".to_string());