Serve video gifs when requested
This commit is contained in:
+17
-7
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user