diff --git a/src/ffmpeg.rs b/src/ffmpeg.rs index df2d6e7..56635cb 100644 --- a/src/ffmpeg.rs +++ b/src/ffmpeg.rs @@ -3,7 +3,8 @@ use std::{ process::Stdio, }; -use color_eyre::eyre::{ContextCompat, Result}; +use color_eyre::eyre::{ContextCompat, Result, bail}; +use futures::channel::oneshot; use relm4::{ Sender, tokio::{ @@ -136,11 +137,10 @@ pub async fn convert_video( let mut reader = BufReader::new(stdout).lines(); // make sure the process is actually started and awaited + let (tx, rx) = oneshot::channel(); tokio::spawn(async move { - child - .wait() - .await - .expect("ffmpeg process encountered an error"); + tx.send(child.wait().await) + .expect("could not send exit status"); }); while let Some(line) = reader.next_line().await? { @@ -157,5 +157,10 @@ pub async fn convert_video( } } + let status = rx.await??; + if !status.success() { + bail!("ffmpeg process errored: {status}"); + } + Ok(out_path) }