Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(video): register video chunk in DB only after first frame is written

Louis Beaumontf94cad13df8c
diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs
index 5e81bd912..e011f2f94 100644
--- a/screenpipe-server/src/video.rs
+++ b/screenpipe-server/src/video.rs
@@ -454,7 +454,6 @@ async fn save_frames_as_video(
"Starting new video chunk: {} for monitor {}",
output_file, monitor_id
);
- new_chunk_callback(&output_file);
match start_ffmpeg_process(&output_file, fps).await {
Ok(mut child) => {
@@ -472,6 +471,10 @@ async fn save_frames_as_video(
frame_count += 1;
frames_total += 1;
+ // Register in DB only after first frame is written successfully
+ // This ensures the file has valid headers and content before timeline can request it
+ new_chunk_callback(&output_file);
+
current_ffmpeg = Some(child);
current_stdin = Some(stdin);
info!(