From 7ff2a9653702ca32cb48385d39637cb0131e9e6b Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Fri, 17 Oct 2025 18:45:11 +0800 Subject: [PATCH 1/2] don't abort encoding if capurer stop fails --- crates/recording/src/output_pipeline/core.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs index 700d3894347..1199dcf3a80 100644 --- a/crates/recording/src/output_pipeline/core.rs +++ b/crates/recording/src/output_pipeline/core.rs @@ -432,7 +432,9 @@ fn spawn_video_encoder, TVideo: V }) .await; - video_source.stop().await.context("video_source_stop")?; + if let Err(e) = video_source.stop().await { + error!("Video source stopped with error: {e:#}"); + }; muxer.lock().await.stop(); From 432af2eaa5462da8a828164aefdf0aa34a523202 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Fri, 17 Oct 2025 18:56:59 +0800 Subject: [PATCH 2/2] separate capture-video task --- crates/recording/src/output_pipeline/core.rs | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs index 1199dcf3a80..b60777eec90 100644 --- a/crates/recording/src/output_pipeline/core.rs +++ b/crates/recording/src/output_pipeline/core.rs @@ -405,13 +405,26 @@ fn spawn_video_encoder, TVideo: V muxer: Arc>, timestamps: Timestamps, ) { + setup_ctx.tasks().spawn("capture-video", { + let stop_token = stop_token.clone(); + async move { + video_source.start().await?; + + stop_token.cancelled().await; + + if let Err(e) = video_source.stop().await { + error!("Video source stop failed: {e:#}"); + }; + + Ok(()) + } + }); + setup_ctx.tasks().spawn("mux-video", async move { use futures::StreamExt; let mut first_tx = Some(first_tx); - video_source.start().await?; - stop_token .run_until_cancelled(async { while let Some(frame) = video_rx.next().await { @@ -432,10 +445,6 @@ fn spawn_video_encoder, TVideo: V }) .await; - if let Err(e) = video_source.stop().await { - error!("Video source stopped with error: {e:#}"); - }; - muxer.lock().await.stop(); Ok(())