mirror of
https://github.com/lrsjng/h5ai
synced 2025-12-06 08:52:45 +01:00
Add seek-in value option for video thumbnails
* Allows users to specify which percentage of the total video duration to seek in instead of hardcoding 15%. * Now defaults to 50%.
This commit is contained in:
parent
7cf18b60f9
commit
5a0c63056c
2 changed files with 12 additions and 6 deletions
|
|
@ -356,6 +356,7 @@
|
||||||
- doc: array of strings
|
- doc: array of strings
|
||||||
- delay: number, delay in milliseconds after "dom-ready" before thumb-requesting starts
|
- delay: number, delay in milliseconds after "dom-ready" before thumb-requesting starts
|
||||||
- size: number, size in pixel of the generated thumbnails
|
- 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
|
- exif: boolean, use included EXIF thumbs if possible
|
||||||
- chunksize: int, number of thumbs per request
|
- chunksize: int, number of thumbs per request
|
||||||
*/
|
*/
|
||||||
|
|
@ -366,6 +367,7 @@
|
||||||
"doc": ["x-pdf", "x-ps"],
|
"doc": ["x-pdf", "x-ps"],
|
||||||
"delay": 1,
|
"delay": 1,
|
||||||
"size": 240,
|
"size": 240,
|
||||||
|
"seek": 50,
|
||||||
"exif": false,
|
"exif": false,
|
||||||
"chunksize": 20
|
"chunksize": 20
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,17 @@ class Thumb {
|
||||||
foreach ($cmdv as &$arg) {
|
foreach ($cmdv as &$arg) {
|
||||||
$arg = str_replace('[H5AI_SRC]', $source_path, $arg);
|
$arg = str_replace('[H5AI_SRC]', $source_path, $arg);
|
||||||
}
|
}
|
||||||
$result = Util::exec_cmdv($cmdv);
|
$duration = Util::exec_cmdv($cmdv);
|
||||||
if (empty($result) || !is_numeric($result) || is_infinite($result)) {
|
if (empty($duration) || !is_numeric($duration) || is_infinite($duration)) {
|
||||||
// Force seeking at 1 second in
|
return "0.1";
|
||||||
return "1";
|
|
||||||
}
|
}
|
||||||
// Seek at 15% of the total video duration
|
// Seek at user-defined percentage of the total video duration
|
||||||
return strval(round(((floatval($result) * 15) / 100), 1, PHP_ROUND_HALF_UP));
|
return strval(
|
||||||
|
round(
|
||||||
|
(floatval($duration) *
|
||||||
|
floatval($this->context->query_option('thumbnails.seek', 50)) / 100),
|
||||||
|
1, PHP_ROUND_HALF_UP)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue