Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Track last frame timestamp in SegmentedAudioEncoder
Richie McIlroy130fe169ce7f
diff --git a/crates/enc-ffmpeg/src/mux/segmented_audio.rs b/crates/enc-ffmpeg/src/mux/segmented_audio.rsindex 0b4c27eb6..b00f7c4a3 100644--- a/crates/enc-ffmpeg/src/mux/segmented_audio.rs+++ b/crates/enc-ffmpeg/src/mux/segmented_audio.rs@@ -12,6 +12,7 @@ pub struct SegmentedAudioEncoder {current_index: u32,segment_duration: Duration,segment_start_time: Option<Duration>,+ last_frame_timestamp: Option<Duration>,completed_segments: Vec<SegmentInfo>,}@@ -87,6 +88,7 @@ impl SegmentedAudioEncoder {current_index: 0,segment_duration,segment_start_time: None,+ last_frame_timestamp: None,completed_segments: Vec::new(),})}@@ -125,6 +127,8 @@ impl SegmentedAudioEncoder {self.segment_start_time = Some(timestamp);}+ self.last_frame_timestamp = Some(timestamp);+let segment_elapsed =timestamp.saturating_sub(self.segment_start_time.unwrap_or(Duration::ZERO));@@ -205,15 +209,15 @@ impl SegmentedAudioEncoder {if let Some(mut encoder) = self.current_encoder.take() {if encoder.has_frames {if let Some(segment_start) = self.segment_start_time {- let final_duration = Duration::from_secs(5);+ let final_duration = self+ .last_frame_timestamp+ .unwrap_or(segment_start)+ .saturating_sub(segment_start);self.completed_segments.push(SegmentInfo {path: self.current_segment_path(),index: self.current_index,- duration: final_duration.saturating_sub(- final_duration- .saturating_sub(segment_start.saturating_sub(segment_start)),- ),+ duration: final_duration,});}diff --git a/crates/enc-ffmpeg/src/remux.rs b/crates/enc-ffmpeg/src/remux.rsindex 41b0d1f0e..cf858002e 100644--- a/crates/enc-ffmpeg/src/remux.rs+++ b/crates/enc-ffmpeg/src/remux.rs@@ -290,7 +290,6 @@ pub fn probe_video_can_decode(path: &Path) -> Result<bool, String> {.map_err(|e| format!("Failed to create video decoder: {e}"))?;let stream_index = input_stream.index();- drop(input_stream);let mut input = avformat::input(path).map_err(|e| format!("Failed to reopen file: {e}"))?;