From: Vincent Vanwaelscappel Date: Tue, 29 Mar 2022 12:30:39 +0000 (+0200) Subject: wip #5184 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=00f96ad4cdd9d157a9c66ae245a136e7c79ce0d5;p=fluidbook_tools.git wip #5184 @0.25 --- diff --git a/src/Links/VideoLink.php b/src/Links/VideoLink.php index 5fa3156..ba457c6 100644 --- a/src/Links/VideoLink.php +++ b/src/Links/VideoLink.php @@ -2,7 +2,9 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Files\Files; use Cubist\Util\Url; +use Illuminate\Support\Facades\Cache; class VideoLink extends Link { @@ -80,16 +82,19 @@ class VideoLink extends Link $attr['width'] = $w; $attr['height'] = $h; } else if (!is_null($compiler) && Url::isLocal($data->to)) { - // Get video dimensions from thumbnail if possible (locally uploaded files) $path = file_exists($data->to) ? $data->to : $compiler->wdir . '/' . $data->to; - $e = explode(',', `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 $path`); - if (count($e) > 1) { - $attr['width'] = $e[0]; - $attr['height'] = $e[1]; - } else { - $attr['width'] = 1920; - $attr['height'] = 1080; - } + + $dim = Cache::get('videosize_' . Files::hashFileAttributes($path), function () use ($path) { + $e = explode(',', `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 $path`); + $res = ['width' => 1920, 'height' => 1080]; + if (count($e) > 1) { + $res['width'] = $e[0]; + $res['height'] = $e[1]; + } + return $res; + }); + // Get video dimensions from thumbnail if possible (locally uploaded files) + $attr = array_merge($attr, $dim); } return $attr;