From c1c73c0b0eb7a6172cc84d541d31e57d3e9e6d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 21 Aug 2023 19:43:47 +0200 Subject: [PATCH] [pp:ugoira] add '"framerate": "uniform"' (#4421) --- docs/configuration.rst | 2 ++ gallery_dl/postprocessor/ugoira.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 190ff91a..c29b2230 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -4906,6 +4906,8 @@ Description * ``"auto"``: Automatically assign a fitting frame rate based on delays between frames. + * ``"uniform"``: Like ``auto``, but assign an explicit frame rate + only to Ugoira with uniform frame delays. * any other ``string``: Use this value as argument for ``-r``. * ``null`` or an empty ``string``: Don't set an explicit frame rate. diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py index 8e84d5c0..b713c6f3 100644 --- a/gallery_dl/postprocessor/ugoira.py +++ b/gallery_dl/postprocessor/ugoira.py @@ -36,6 +36,7 @@ class UgoiraPP(PostProcessor): self.delete = not options.get("keep-files", False) self.repeat = options.get("repeat-last-frame", True) self.mtime = options.get("mtime", True) + self.uniform = False ffmpeg = options.get("ffmpeg-location") self.ffmpeg = util.expand_path(ffmpeg) if ffmpeg else "ffmpeg" @@ -63,7 +64,9 @@ class UgoiraPP(PostProcessor): self.log.debug("using %s demuxer", demuxer) rate = options.get("framerate", "auto") - if rate != "auto": + if rate == "uniform": + self.uniform = True + elif rate != "auto": self.calculate_framerate = lambda _: (None, rate) if options.get("libx264-prevent-odd", True): @@ -285,9 +288,10 @@ class UgoiraPP(PostProcessor): if self._delay_is_uniform(frames): return ("1000/{}".format(frames[0]["delay"]), None) - gcd = self._delay_gcd(frames) - if gcd >= 10: - return (None, "1000/{}".format(gcd)) + if not self.uniform: + gcd = self._delay_gcd(frames) + if gcd >= 10: + return (None, "1000/{}".format(gcd)) return (None, None)