From 6029f92aada98d17cb96c9d9760c752f29f0ad67 Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Sun, 11 Nov 2018 05:54:57 +0100 Subject: [PATCH] Scale videos properly. Previously there was an issue with vertical or squared videos bigger than 720 pixels high. Also sets timestamp for videoCreateDate even if nothing is found. Done to avoid cache corruption when walking the albums. --- scanner/PhotoAlbum.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py index 5083557..02ca635 100644 --- a/scanner/PhotoAlbum.py +++ b/scanner/PhotoAlbum.py @@ -278,7 +278,11 @@ class Photo(object): break # use time from EXIF (rather than file creation) - if info['format']['tags']['creation_time']: + try: + info['format']['tags']['creation_time'] + except KeyError: + self._attributes["videoCreateDate"] = self._attributes["dateTimeFile"] + else: # we have time modifiable via exif # lets use this @@ -470,9 +474,19 @@ class Photo(object): if os.path.exists(transcode_path) and file_mtime(transcode_path) >= self._attributes["dateTimeFile"]: self._video_metadata(transcode_path, False) return - if "originalSize" in self._attributes and self._attributes["originalSize"][1] > 720: - transcode_cmd.append('-s') - transcode_cmd.append('hd720') + if "originalSize" in self._attributes: + width = self._attributes["originalSize"][0] + height = self._attributes["originalSize"][1] + if width > height: + # horisontal orientation + if height > 720: + transcode_cmd.append('-vf') + transcode_cmd.append('scale=-1:720') + elif (height > width) or (width == height): + # vertical orientation, or equal sides + if width > 720: + transcode_cmd.append('-vf') + transcode_cmd.append('scale=720:-1') if "rotate" in self._attributes: if self._attributes["rotate"] == "90": filters.append('transpose=1')