Skip to content

Commit

Permalink
Properly log errors in Movie previews generation
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv committed Aug 19, 2021
1 parent eb77a4b commit 7cd9dfa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private function getMaxPreview(ISimpleFolder $previewFolder, File $file, $mimeTy

$previewProviders = $this->previewManager->getProviders();
foreach ($previewProviders as $supportedMimeType => $providers) {
// Filter out providers that does not support this mime
if (!preg_match($supportedMimeType, $mimeType)) {
continue;
}
Expand Down
11 changes: 8 additions & 3 deletions lib/private/Preview/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

use OCP\Files\File;
use OCP\IImage;
use Psr\Log\LoggerInterface;

class Movie extends ProviderV2 {
public static $avconvBinary;
Expand Down Expand Up @@ -78,13 +79,13 @@ private function generateThumbNail($maxX, $maxY, $absPath, $second): ?IImage {
$cmd = self::$avconvBinary . ' -y -ss ' . escapeshellarg($second) .
' -i ' . escapeshellarg($absPath) .
' -an -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) .
' > /dev/null 2>&1';
' 2>&1';
} else {
$cmd = self::$ffmpegBinary . ' -y -ss ' . escapeshellarg($second) .
' -i ' . escapeshellarg($absPath) .
' -f mjpeg -vframes 1' .
' -f mjpeg -vfcrames 1' .
' ' . escapeshellarg($tmpPath) .
' > /dev/null 2>&1';
' 2>&1';
}

exec($cmd, $output, $returnCode);
Expand All @@ -99,6 +100,10 @@ private function generateThumbNail($maxX, $maxY, $absPath, $second): ?IImage {
return $image;
}
}

$logger = \OC::$server->get(LoggerInterface::class);
$logger->error('Movie preview generation failed Output: {output}', ['app' => 'core', 'output' => $output]);

unlink($tmpPath);
return null;
}
Expand Down

0 comments on commit 7cd9dfa

Please sign in to comment.