Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(enc-ffmpeg): flush segmented-stream manifest after draining pending fragments

Richie McIlroy3448d462be81
diff --git a/crates/enc-ffmpeg/src/mux/segmented_stream.rs b/crates/enc-ffmpeg/src/mux/segmented_stream.rs
index 92462eb51..eb666b916 100644
--- a/crates/enc-ffmpeg/src/mux/segmented_stream.rs
+++ b/crates/enc-ffmpeg/src/mux/segmented_stream.rs
@@ -450,9 +450,11 @@ impl SegmentedVideoEncoder {
return;
}
+ let taken = std::mem::take(&mut self.pending_segment_indices);
+ let taken_len = taken.len();
let mut still_pending = Vec::new();
- for (index, duration) in std::mem::take(&mut self.pending_segment_indices) {
+ for (index, duration) in taken {
let segment_path = self.base_path.join(format!("segment_{index:03}.m4s"));
let tmp_path = self.base_path.join(format!("segment_{index:03}.m4s.tmp"));
@@ -501,11 +503,12 @@ impl SegmentedVideoEncoder {
});
}
- if !still_pending.is_empty() {
+ let flushed_any = still_pending.len() < taken_len;
+ self.pending_segment_indices = still_pending;
+
+ if flushed_any {
self.write_in_progress_manifest();
}
-
- self.pending_segment_indices = still_pending;
}
fn current_segment_path(&self) -> PathBuf {