From 4f40efa99cb0e3db10a30889d766b9c4f3f96a4d Mon Sep 17 00:00:00 2001 From: kieran Date: Mon, 27 Jan 2025 22:57:16 +0000 Subject: [PATCH] fix: negative duration --- src/filesystem.rs | 4 +++- src/processing/mod.rs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/filesystem.rs b/src/filesystem.rs index bd4fbc0..6dbcbc5 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -106,7 +106,9 @@ impl FileStore { v_stream.map(|v| v.width as u32), v_stream.map(|v| v.height as u32), mime, - probe.as_ref().map(|p| p.duration), + probe + .as_ref() + .map(|p| if p.duration < 0. { 0.0 } else { p.duration }), probe.as_ref().map(|p| p.bitrate as u32), ) } diff --git a/src/processing/mod.rs b/src/processing/mod.rs index 1d9104e..e9f320b 100644 --- a/src/processing/mod.rs +++ b/src/processing/mod.rs @@ -66,7 +66,11 @@ impl WebpProcessor { mime_type: "image/webp".to_string(), width: image_stream.width, height: image_stream.height, - duration: probe.duration, + duration: if probe.duration < 0. { + 0. + } else { + probe.duration + }, bitrate: probe.bitrate as u32, }) }