diff --git a/src/_h5ai/private/conf/options.json b/src/_h5ai/private/conf/options.json index a570da26..bccde678 100644 --- a/src/_h5ai/private/conf/options.json +++ b/src/_h5ai/private/conf/options.json @@ -356,6 +356,7 @@ - doc: array of strings - delay: number, delay in milliseconds after "dom-ready" before thumb-requesting starts - size: number, size in pixel of the generated thumbnails + - seek: number, percentage of total video duration to seek into - exif: boolean, use included EXIF thumbs if possible - chunksize: int, number of thumbs per request */ @@ -366,6 +367,7 @@ "doc": ["x-pdf", "x-ps"], "delay": 1, "size": 240, + "seek": 50, "exif": false, "chunksize": 20 }, diff --git a/src/_h5ai/private/php/ext/class-thumb.php b/src/_h5ai/private/php/ext/class-thumb.php index 6c7de23a..0174a607 100644 --- a/src/_h5ai/private/php/ext/class-thumb.php +++ b/src/_h5ai/private/php/ext/class-thumb.php @@ -124,13 +124,17 @@ class Thumb { foreach ($cmdv as &$arg) { $arg = str_replace('[H5AI_SRC]', $source_path, $arg); } - $result = Util::exec_cmdv($cmdv); - if (empty($result) || !is_numeric($result) || is_infinite($result)) { - // Force seeking at 1 second in - return "1"; + $duration = Util::exec_cmdv($cmdv); + if (empty($duration) || !is_numeric($duration) || is_infinite($duration)) { + return "0.1"; } - // Seek at 15% of the total video duration - return strval(round(((floatval($result) * 15) / 100), 1, PHP_ROUND_HALF_UP)); + // Seek at user-defined percentage of the total video duration + return strval( + round( + (floatval($duration) * + floatval($this->context->query_option('thumbnails.seek', 50)) / 100), + 1, PHP_ROUND_HALF_UP) + ); } }