Serve video gifs when requested

This commit is contained in:
Cameron
2025-07-02 15:48:49 -04:00
parent 3fbdba2b9c
commit e5afdd909b
7 changed files with 187 additions and 41 deletions
+17 -7
View File
@@ -156,7 +156,7 @@ impl Ffmpeg {
}
async fn create_gif_from_frames(&self, frame_base_dir: &str, output_file: &str) -> Result<i32> {
Command::new("ffmpeg")
let output = Command::new("ffmpeg")
.arg("-y")
.args(["-framerate", "4"])
.args(["-i", &format!("{}/frame_%03d.jpg", frame_base_dir)])
@@ -169,10 +169,20 @@ impl Ffmpeg {
.args(["-loop", "0"]) // loop forever
.args(["-final_delay", "75"])
.arg(output_file)
.stderr(Stdio::null())
.status()
.map_ok(|out| out.code().unwrap_or(-1))
.inspect_ok(|output| debug!("ffmpeg gif create exit code: {:?}", output))
.await
.stderr(Stdio::piped()) // Change this to capture stderr
.stdout(Stdio::piped()) // Optionally capture stdout too
.output()
.await?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
error!("FFmpeg error: {}", stderr);
let stdout = String::from_utf8_lossy(&output.stdout);
debug!("FFmpeg stdout: {}", stdout);
} else {
debug!("FFmpeg successful with exit code: {}", output.status);
}
Ok(output.status.code().unwrap_or(-1))
}
}
}