From 32542213e6e94f74076e76f3f52e8e028cf491ef Mon Sep 17 00:00:00 2001 From: amietn Date: Sun, 17 Mar 2019 18:03:04 +0100 Subject: [PATCH] swap width and height for videos with rotate 90 (#58) --- vcsi/vcsi.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vcsi/vcsi.py b/vcsi/vcsi.py index 5e8f8af..65c1da9 100755 --- a/vcsi/vcsi.py +++ b/vcsi/vcsi.py @@ -170,6 +170,17 @@ def compute_display_resolution(self): """ self.sample_width = int(self.video_stream["width"]) self.sample_height = int(self.video_stream["height"]) + + # videos recorded with a smartphone may have a "rotate" flag + try: + rotation = int(self.video_stream["tags"]["rotate"]) + except KeyError: + rotation = None + + if rotation == 90: + # swap width and height + self.sample_width, self.sample_height = self.sample_height, self.sample_width + sample_aspect_ratio = "1:1" try: sample_aspect_ratio = self.video_stream["sample_aspect_ratio"]