perf: correct `ffmpeg` params for efficient video previews

-ss before -i ("When used as an output option (before an output url), decodes but discards input until the timestamps reach position. ")
discard all non-keyframes
turn off accurate seek
feat/type-attributes
Tomáš Mládek 2022-09-11 20:33:41 +02:00
parent e48e007617
commit 327b87a18a
1 changed files with 4 additions and 1 deletions

View File

@ -30,9 +30,12 @@ impl<'a> Previewable for VideoPath<'a> {
let outfile = tempfile::Builder::new().suffix(".webp").tempfile()?;
let thumbnail_cmd = Command::new("ffmpeg")
.args(["-threads", "1"])
.args(["-discard", "nokey"])
.args(["-noaccurate_seek"])
.args(["-ss", &(90f64.min(duration / 2.0)).to_string()])
.args(["-i", &self.0.to_string_lossy()])
.args(["-vframes", "1"])
.args(["-ss", &(90f64.min(duration / 2.0)).to_string()])
.args(["-vsync", "passthrough"])
.arg(&*outfile.path().to_string_lossy())
.arg("-y")
.output()?;