From 63cca29ce46df3364e553b746840718fb55f4dc1 Mon Sep 17 00:00:00 2001 From: lgaribaldi Date: Thu, 4 Jan 2024 11:43:49 -0300 Subject: [PATCH] Add check for rotate tag When a video has a "rotate" tag in metadata, the video player rotates when playing the video, giving it a portrait perspective. Because of this, the width is still larger than height even in a portrait video. Which causes the stride to be off and the resulting frame to be scrambled. This can be fixed by inverting the widht and height of the video when there is a rotation. --- video.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/video.go b/video.go index 7cdb8a8..b22371a 100644 --- a/video.go +++ b/video.go @@ -168,6 +168,9 @@ func (video *Video) addVideoData(data map[string]string) { if height, ok := data["height"]; ok { video.height = int(parse(height)) } + if rotation, ok := data["tag:rotate"]; ok && (rotation == "90" || rotation == "270") { + video.width, video.height = video.height, video.width + } if duration, ok := data["duration"]; ok { video.duration = float64(parse(duration)) }