Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Dec 8, 2024
1 parent 61f4303 commit 190937f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion www/controllers/Motion/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,32 @@ public function attachFile(string $motionEventId, string $file, int $width, int
* Create thumbnail if not already exist
*/
if (!file_exists($file . '.thumbnail')) {
/**
* First, get the duration of the movie
*/
$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 duration has been found, then create thumbnail
*/
if (!empty($output)) {
$duration = $output;

/**
* Convert duration to seconds
*/
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');
/**
* Create thumbnail at the middle of the movie
*/
$myprocess = new \Controllers\Process('/usr/bin/ffmpeg -loglevel error -ss ' . gmdate("H:i:s", $totalSeconds / 2) . ' -i ' . $file . " -vf 'scale=320:320:force_original_aspect_ratio=decrease' -vframes 1 " . $file . '.thumbnail.jpg');
$myprocess->execute();
$output = $myprocess->getOutput();
$myprocess->close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion www/controllers/Service/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ private function runService(string $name, string $parameter, bool $force = false
* If force != false, then the service will be run even if it is already running (e.g: for running multiple scheduled tasks at the same time)
*/
if ($force === false) {
$myprocess = new \Controllers\Process('/usr/bin/ps aux | grep "repomanager.' . $parameter . '" | grep -v grep');
$myprocess = new \Controllers\Process('/usr/bin/ps aux | grep "motionui.' . $parameter . '" | grep -v grep');
$myprocess->execute();
$content = $myprocess->getOutput();
$myprocess->close();
Expand Down

0 comments on commit 190937f

Please sign in to comment.