diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs index 700d38943..b60777eec 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,8 +445,6 @@ fn spawn_video_encoder, TVideo: V }) .await; - video_source.stop().await.context("video_source_stop")?; - muxer.lock().await.stop(); Ok(())