[PLUGIN][VideoEncoder] Some videos don't have images (video stream), only audio, handle that

This commit is contained in:
2021-12-03 03:13:28 +00:00
parent 4501b7e85e
commit 044649c745
4 changed files with 42 additions and 30 deletions

View File

@@ -54,7 +54,8 @@ class VideoEncoder extends Plugin
return '1.0.0';
}
public static function shouldHandle (string $mimetype): bool {
public static function shouldHandle(string $mimetype): bool
{
return GSFile::mimetypeMajor($mimetype) === 'video' || $mimetype === 'image/gif';
}
@@ -107,10 +108,12 @@ class VideoEncoder extends Plugin
]);
$metadata = $ffprobe->streams($file->getRealPath()) // extracts streams informations
->videos() // filters video streams
->first(); // returns the first video stream
$width = $metadata->get('width');
$height = $metadata->get('height');
->videos() // filters video streams
->first(); // returns the first video stream
if (!\is_null($metadata)) {
$width = $metadata->get('width');
$height = $metadata->get('height');
}
return true;
}