fix: limit thumbnail generation to 1 thread per image

feat/type-attributes
Tomáš Mládek 2022-09-07 22:28:14 +02:00
parent 457242c9a9
commit e0a9ee1c96
1 changed files with 2 additions and 0 deletions

View File

@ -12,6 +12,7 @@ pub struct VideoPath<'a>(pub &'a Path);
impl<'a> Previewable for VideoPath<'a> {
fn get_thumbnail(&self) -> Result<Option<Vec<u8>>> {
let duration_cmd = Command::new("ffprobe")
.args(["-threads", "1"])
.args(["-v", "error"])
.args(["-show_entries", "format=duration"])
.args(["-of", "default=noprint_wrappers=1:nokey=1"])
@ -28,6 +29,7 @@ impl<'a> Previewable for VideoPath<'a> {
.parse::<f64>()?;
let outfile = tempfile::Builder::new().suffix(".webp").tempfile()?;
let thumbnail_cmd = Command::new("ffmpeg")
.args(["-threads", "1"])
.args(["-i", &self.0.to_string_lossy()])
.args(["-vframes", "1"])
.args(["-ss", &(300f64.min(duration / 4.0)).to_string()])