Nimm die kleine Filmstufe für die Titelbildwahl und verankere Hinweise ohne neue Fassung.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c47c3b9b32
commit
f86032cb5f
14 files changed
+283
-46
No files matched your search
@@ -83,24 +83,36 @@ public function forCompositionFrame(Composition $composition, ContentElementVers
|
||||
$this->rememberChoice($composition, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
||||
}
|
||||
|
||||
public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string
|
||||
public function frameInput(ContentElementVersion $version): ?string
|
||||
{
|
||||
$file = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null;
|
||||
$proxy = MediaRendition::query()
|
||||
->where('content_element_version_id', $version->id)
|
||||
->where('role', 'variant')
|
||||
->where('label', '480')
|
||||
->value('path');
|
||||
|
||||
if (! is_string($file) || $file === '' || str_contains($file, '..') || ! str_starts_with($file, 'inhalte/')) {
|
||||
return null;
|
||||
if (is_string($proxy) && $this->readableDerived($proxy, 'ableitungen/')) {
|
||||
return $proxy;
|
||||
}
|
||||
|
||||
$file = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null;
|
||||
|
||||
return $this->readableDerived($file, 'inhalte/') ? $file : null;
|
||||
}
|
||||
|
||||
public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string
|
||||
{
|
||||
if ($seconds < 0 || $seconds > 7200) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$disk = Storage::disk('media_derived');
|
||||
$file = $this->frameInput($version);
|
||||
|
||||
if (! $disk->exists($file)) {
|
||||
if ($file === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$disk = Storage::disk('media_derived');
|
||||
$binary = (new ExecutableFinder)->find('ffmpeg');
|
||||
|
||||
if ($binary === null) {
|
||||
@@ -112,19 +124,21 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?
|
||||
'-hide_banner',
|
||||
'-loglevel',
|
||||
'error',
|
||||
'-i',
|
||||
$disk->path($file),
|
||||
'-ss',
|
||||
$this->secondText($seconds),
|
||||
'-i',
|
||||
$disk->path($file),
|
||||
'-frames:v',
|
||||
'1',
|
||||
'-vf',
|
||||
'scale=640:-2',
|
||||
'-f',
|
||||
'image2pipe',
|
||||
'-vcodec',
|
||||
'mjpeg',
|
||||
'pipe:1',
|
||||
]);
|
||||
$process->setTimeout(30);
|
||||
$process->setTimeout(15);
|
||||
$process->run();
|
||||
$bytes = $process->getOutput();
|
||||
|
||||
@@ -135,6 +149,15 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
private function readableDerived(mixed $path, string $prefix): bool
|
||||
{
|
||||
if (! is_string($path) || $path === '' || str_contains($path, '..') || ! str_starts_with($path, $prefix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Storage::disk('media_derived')->exists($path);
|
||||
}
|
||||
|
||||
private function secondText(float $seconds): string
|
||||
{
|
||||
$seconds = max(0, min(7200, $seconds));
|
||||
|
||||
Reference in new issue
Block a user