diff --git a/src/rust/ffmpeg.rs b/src/rust/ffmpeg.rs index da9a82f..4c405dd 100644 --- a/src/rust/ffmpeg.rs +++ b/src/rust/ffmpeg.rs @@ -7,7 +7,10 @@ use std::process::Command; use std::str; use tracing::debug; -pub async fn bg_from_video(video: &Path, screenshot: &Path) -> Result<(), Box> { +pub fn bg_from_video( + video: &Path, + screenshot: &Path, +) -> Result<(), Box> { if !screenshot.exists() { let output_duration = Command::new("ffprobe") .args(&["-i", &video.to_string_lossy()]) @@ -82,32 +85,41 @@ pub fn bg_path_from_video(video: &Path) -> PathBuf { screenshot } - #[cfg(test)] mod test { use super::*; #[test] fn test_bg_video_creation() { - let video = Path::new("/home/chris/vids/All WebDev Sucks and you know it.webm"); + let video = Path::new( + "/home/chris/vids/All WebDev Sucks and you know it.webm", + ); let screenshot = bg_path_from_video(video); - let screenshot_string = screenshot.to_str().expect("Should be thing"); + let screenshot_string = + screenshot.to_str().expect("Should be thing"); assert_eq!(screenshot_string, "/home/chris/.local/share/lumina/thumbnails/All WebDev Sucks and you know it.png"); - let runtime = tokio::runtime::Runtime::new().unwrap(); - let future = bg_from_video(video, &screenshot); - let result = runtime.block_on(future); + // let runtime = tokio::runtime::Runtime::new().unwrap(); + let result = bg_from_video(video, &screenshot); + // let result = runtime.block_on(future); match result { Ok(o) => assert_eq!(screenshot.exists(), true), - Err(e) => debug_assert!(false, "There was an error in the runtime future. {:?}", e) + Err(e) => debug_assert!( + false, + "There was an error in the runtime future. {:?}", + e + ), } } #[test] fn test_bg_not_same() { - let video = Path::new("/home/chris/vids/All WebDev Sucks and you know it.webm"); + let video = Path::new( + "/home/chris/vids/All WebDev Sucks and you know it.webm", + ); let screenshot = bg_path_from_video(video); - let screenshot_string = screenshot.to_str().expect("Should be thing"); + let screenshot_string = + screenshot.to_str().expect("Should be thing"); assert_ne!(screenshot_string, "/home/chris/.local/share/lumina/thumbnails/All WebDev Sucks and you know it.webm"); } } diff --git a/src/rust/slide_model.rs b/src/rust/slide_model.rs index 7c46cd2..adcd3bf 100644 --- a/src/rust/slide_model.rs +++ b/src/rust/slide_model.rs @@ -331,9 +331,9 @@ impl slide_model::SlideModel { screenshot.to_str().unwrap() ).insert(0, &QString::from("file://")).to_owned(); slide.video_thumbnail = screenshot_string; - let runtime = tokio::runtime::Runtime::new().unwrap(); - runtime.spawn(async move { - let result = ffmpeg::bg_from_video(&path, &screenshot).await; + // let runtime = tokio::runtime::Runtime::new().unwrap(); + std::thread::spawn(move || { + let result = ffmpeg::bg_from_video(&path, &screenshot); match result { Ok(_o) => debug!("Success making video background!"), Err(error) => error!(?error, "Error making video background") @@ -426,15 +426,7 @@ impl slide_model::SlideModel { self.as_mut().rust_mut().slides.push(slide); self.as_mut().end_insert_rows(); } - let thread = self.qt_thread(); - thread::spawn(move || { - thread - .queue(move |slidemodel| { - slidemodel.add_video_thumbnail(index); - }) - .unwrap(); - }); - // self.as_mut().add_video_thumbnail(index); + self.as_mut().add_video_thumbnail(index); } fn insert_slide(