From 2e1218cfd1a93d8fdeb230acc58ef5d050d85f8f Mon Sep 17 00:00:00 2001 From: Grischa Erbe Date: Fri, 21 Feb 2025 01:33:16 +0100 Subject: [PATCH] Handle dimensions of rotated videos --- src/Assets/Attributes.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Assets/Attributes.php b/src/Assets/Attributes.php index 010de336cc..fe85840235 100644 --- a/src/Assets/Attributes.php +++ b/src/Assets/Attributes.php @@ -88,10 +88,19 @@ private function getVideoAttributes() { $id3 = ExtractInfo::fromAsset($this->asset); + $width = Arr::get($id3, 'video.resolution_x'); + $height = Arr::get($id3, 'video.resolution_y'); + $rotate = Arr::get($id3, 'video.rotate', 0); + + // Adjust width and height if the video is rotated + if (in_array($rotate, [90, 270, -90, -270])) { + list($width, $height) = [$height, $width]; + } + return [ - 'width' => Arr::get($id3, 'video.resolution_x'), - 'height' => Arr::get($id3, 'video.resolution_y'), - 'duration' => Arr::get($id3, 'playtime_seconds'), + 'width' => $width, + 'height' => $height, + 'duration' => Arr::get($id3, 'playtime_seconds') ]; } }