static preview frame on slider release
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user