From 1f1afb32233823b3eb2ede0988574f244d880faa Mon Sep 17 00:00:00 2001 From: Ludovic <54670129+lbr38@users.noreply.github.com> Date: Sun, 8 Dec 2024 16:50:54 +0100 Subject: [PATCH] patch --- www/controllers/Motion/Event.php | 13 ++++++++++++- .../containers/motionui/service/status.inc.php | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/www/controllers/Motion/Event.php b/www/controllers/Motion/Event.php index 49fe1883..52a2374c 100644 --- a/www/controllers/Motion/Event.php +++ b/www/controllers/Motion/Event.php @@ -120,9 +120,20 @@ public function attachFile(string $motionEventId, string $file, int $width, int * Create thumbnail if not already exist */ if (!file_exists($file . '.thumbnail')) { - $myprocess = new \Controllers\Process('/usr/bin/ffmpeg -loglevel error -ss 00:00:00.10 -i ' . $file . ' -vf \'scale=320:320:force_original_aspect_ratio=decrease\' -vframes 1 ' . $file . '.thumbnail.jpg'); + $myprocess = new \Controllers\Process("/usr/bin/ffmpeg -i " . $file . " 2>&1 | grep 'Duration' | awk '{print $2}' | tr -d ,"); $myprocess->execute(); + $output = $myprocess->getOutput(); $myprocess->close(); + + if (!empty($output)) { + $duration = $output; + list($hours, $minutes, $seconds) = explode(":", $duration); + $totalSeconds = ($hours * 3600) + ($minutes * 60) + $seconds; + + $myprocess = new \Controllers\Process('/usr/bin/ffmpeg -loglevel error -ss ' . gmdate("H:i:s", $thumbnailTime) . '-i ' . $file . " -vf 'scale=320:320:force_original_aspect_ratio=decrease' -vframes 1 " . $file . '.thumbnail.jpg'); + $myprocess->execute(); + $myprocess->close(); + } } } diff --git a/www/views/includes/containers/motionui/service/status.inc.php b/www/views/includes/containers/motionui/service/status.inc.php index 70043d9a..c3719216 100644 --- a/www/views/includes/containers/motionui/service/status.inc.php +++ b/www/views/includes/containers/motionui/service/status.inc.php @@ -4,8 +4,9 @@ * Display a warning if motionUI service is not running */ if ($mymotionService->motionuiServiceRunning() !== true) : ?> -
-

motionui service is not running. Please restart the docker container.

+
+ +

motionui service is not running. Please restart the docker container.