forked from GNUsocial/gnu-social
[PLUGIN][VideoEncoder] Some videos don't have images (video stream), only audio, handle that
This commit is contained in:
parent
4501b7e85e
commit
044649c745
@ -1,3 +1,4 @@
|
||||
{% if attachment.getFilename() is not null %}
|
||||
<div>
|
||||
<figure>
|
||||
<audio class="u-audio" src="{{ attachment.getUrl() }}" controls>
|
||||
@ -11,3 +12,6 @@
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
{% else %}
|
||||
{# Not stored locally. #}
|
||||
{% endif %}
|
||||
|
@ -69,36 +69,31 @@ class StoreRemoteMedia extends Plugin
|
||||
'.*', // Default to allowing any host
|
||||
];
|
||||
public array $domain_blacklist = [];
|
||||
// Whether to maintain a copy of the original media or only a thumbnail of it
|
||||
public bool $store_original = false;
|
||||
public ?int $thumbnail_width;
|
||||
public ?int $thumbnail_height;
|
||||
public ?int $max_size;
|
||||
public ?bool $smart_crop;
|
||||
|
||||
// Whether to maintain a copy of the original media or only a thumbnail of it
|
||||
private function getStoreOriginal(): bool
|
||||
{
|
||||
return $this->store_original ?? Common::config('plugin_store_remote_media', 'store_original');
|
||||
return Common::config('plugin_store_remote_media', 'store_original');
|
||||
}
|
||||
|
||||
private function getThumbnailWidth(): int
|
||||
{
|
||||
return $this->thumbnail_width ?? Common::config('thumbnail', 'width');
|
||||
return Common::config('thumbnail', 'width');
|
||||
}
|
||||
|
||||
private function getThumbnailHeight(): int
|
||||
{
|
||||
return $this->thumbnail_height ?? Common::config('thumbnail', 'height');
|
||||
return Common::config('thumbnail', 'height');
|
||||
}
|
||||
|
||||
private function getMaxSize(): int
|
||||
private function getMaxFileSize(): int
|
||||
{
|
||||
return $this->max_size ?? Common::config('plugin_store_remote_media', 'max_file_size');
|
||||
return Common::config('plugin_store_remote_media', 'max_file_size');
|
||||
}
|
||||
|
||||
private function getSmartCrop(): bool
|
||||
{
|
||||
return $this->smart_crop ?? Common::config('plugin_store_remote_media', 'smart_crop');
|
||||
return Common::config('plugin_store_remote_media', 'smart_crop');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user