Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
don't bother inserting empty frames where needed
Brendan Allan382733e8a71b
diff --git a/apps/desktop/src-tauri/src/display.rs b/apps/desktop/src-tauri/src/display.rsindex cd25ec8e7..c602feddd 100644--- a/apps/desktop/src-tauri/src/display.rs+++ b/apps/desktop/src-tauri/src/display.rs@@ -187,9 +187,6 @@ pub async fn start_capturing(let mut start_time_tx = Some(tx);- // Hold the last valid RGB frame- let mut last_rgb_frame: Option<ffmpeg::frame::Video> = None;-loop {if controller.is_stopped() {break;@@ -214,25 +211,10 @@ pub async fn start_capturing(if let Some(rgb_frame) =bgra_frame(&frame.data, capture_size[0], capture_size[1]){- // Successfully created RGB frame- last_rgb_frame = Some(rgb_frame.clone());-let mut yuv_frame = Video::empty();scaler.run(&rgb_frame, &mut yuv_frame).unwrap();encoder.encode_frame(yuv_frame, frame.display_time / 1_000_000);- } else if let Some(ref rgb_frame) = last_rgb_frame {- // Use the last valid frame- println!("Using last valid frame due to unexpected frame size.");-- let mut yuv_frame = Video::empty();- scaler.run(rgb_frame, &mut yuv_frame).unwrap();-- // Update the display time to maintain synchronization- encoder.encode_frame(yuv_frame, frame.display_time / 1_000_000);- } else {- // No previous frame to use- println!("No valid frame available to use.");}}_ => println!("Failed to get frame"),diff --git a/apps/desktop/src-tauri/src/encoder.rs b/apps/desktop/src-tauri/src/encoder.rsindex 8dc1bf9ea..6cf24c9d0 100644--- a/apps/desktop/src-tauri/src/encoder.rs+++ b/apps/desktop/src-tauri/src/encoder.rs@@ -82,7 +82,7 @@ impl H264Encoder {pub fn encode_frame(&mut self, mut frame: ffmpeg::util::frame::Video, timestamp: u64) {let last_frame_pts = self.last_frame.as_ref().and_then(|f| f.pts());- if let Some(mut last_frame_pts) = last_frame_pts {+ if let Some(last_frame_pts) = last_frame_pts {let pts = {let delta_time = if let Some(start_time) = self.start_time {(timestamp - start_time) as i64@@ -100,18 +100,6 @@ impl H264Encoder {return;}- // duplicate previous frame if this frame is >1 frame in the future- while pts - 1 > last_frame_pts {- last_frame_pts = last_frame_pts + 1;-- if let Some(last_frame) = &mut self.last_frame {- last_frame.set_pts(Some(last_frame_pts));- self.context.send_frame(&last_frame).unwrap();- }-- self.receive_and_process_packets();- }-frame.set_pts(Some(pts));} else {frame.set_pts(Some(0));@@ -183,12 +171,6 @@ pub fn bgra_frame(bytes: &[u8], width: u32, height: u32) -> Option<ffmpeg::framelet expected_size = (width * height * 4) as usize;if bytes.len() != expected_size {- // Unexpected frame data size- println!(- "Unexpected frame data size: expected {}, got {}",- expected_size,- bytes.len()- );return None;}