static preview frame on slider release

This commit is contained in:
2026-05-12 01:51:32 +03:00
parent 27d7453ea2
commit 2aeb08977b
4 changed files with 130 additions and 0 deletions
+23
View File
@@ -372,6 +372,29 @@ fn estimate_gif_scale_width(req: &TranscodeRequest) -> u32 {
(w / 2) * 2
}
pub fn render_preview(
ffmpeg: &Path,
input: &Path,
out_path: &Path,
midpoint_secs: f64,
target_width: u32,
) -> Result<()> {
if let Some(parent) = out_path.parent() {
std::fs::create_dir_all(parent).context("creating preview parent")?;
}
let scale_filter = format!("scale={}:-2", target_width);
let mut cmd = Command::new(ffmpeg);
cmd.arg("-y")
.arg("-hide_banner")
.args(["-ss", &format!("{midpoint_secs}")])
.arg("-i")
.arg(input)
.args(["-vf", &scale_filter])
.args(["-frames:v", "1"])
.arg(out_path);
run(&mut cmd, "preview render")
}
pub fn extract_thumbnails(
ffmpeg: &Path,
input: &Path,