[PLUGIN][VideoEncoder] Some videos don't have images (video stream), only audio, handle that
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -1,13 +1,23 @@
|
||||
<div>
|
||||
<figure>
|
||||
<video class="u-video" src="{{ attachment.getUrl() }}" controls poster="{{ attachment.getThumbnailUrl('medium')}}">
|
||||
</video>
|
||||
<figcaption>
|
||||
{% if attachment.getFilename() is not null %}
|
||||
<a href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
|
||||
{% else %}
|
||||
{{ attachment.getBestTitle(note) }}
|
||||
{% endif %}
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
{% if attachment.getFilename() is not null %}
|
||||
<div>
|
||||
<figure>
|
||||
<video
|
||||
{% if attachment.getWidth() is not null %}
|
||||
class="u-video"
|
||||
{% else %}
|
||||
class="u-audio"
|
||||
{% endif %}
|
||||
src="{{ attachment.getUrl() }}" controls
|
||||
{% if attachment.getWidth() is not null %}
|
||||
poster="{{ attachment.getThumbnailUrl('medium')}}"
|
||||
{% endif %}
|
||||
>
|
||||
</video>
|
||||
<figcaption>
|
||||
<a href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
{% else %}
|
||||
{# Not stored locally. #}
|
||||
{% endif %}
|
||||
|
Reference in New Issue
Block a user