[pp:ugoira] add '"framerate": "uniform"' (#4421)

pull/4489/head
Mike Fährmann 1 year ago
parent 2a3acd318a
commit c1c73c0b0e
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -4906,6 +4906,8 @@ Description
* ``"auto"``: Automatically assign a fitting frame rate * ``"auto"``: Automatically assign a fitting frame rate
based on delays between frames. 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``. * any other ``string``: Use this value as argument for ``-r``.
* ``null`` or an empty ``string``: Don't set an explicit frame rate. * ``null`` or an empty ``string``: Don't set an explicit frame rate.

@ -36,6 +36,7 @@ class UgoiraPP(PostProcessor):
self.delete = not options.get("keep-files", False) self.delete = not options.get("keep-files", False)
self.repeat = options.get("repeat-last-frame", True) self.repeat = options.get("repeat-last-frame", True)
self.mtime = options.get("mtime", True) self.mtime = options.get("mtime", True)
self.uniform = False
ffmpeg = options.get("ffmpeg-location") ffmpeg = options.get("ffmpeg-location")
self.ffmpeg = util.expand_path(ffmpeg) if ffmpeg else "ffmpeg" self.ffmpeg = util.expand_path(ffmpeg) if ffmpeg else "ffmpeg"
@ -63,7 +64,9 @@ class UgoiraPP(PostProcessor):
self.log.debug("using %s demuxer", demuxer) self.log.debug("using %s demuxer", demuxer)
rate = options.get("framerate", "auto") rate = options.get("framerate", "auto")
if rate != "auto": if rate == "uniform":
self.uniform = True
elif rate != "auto":
self.calculate_framerate = lambda _: (None, rate) self.calculate_framerate = lambda _: (None, rate)
if options.get("libx264-prevent-odd", True): if options.get("libx264-prevent-odd", True):
@ -285,6 +288,7 @@ class UgoiraPP(PostProcessor):
if self._delay_is_uniform(frames): if self._delay_is_uniform(frames):
return ("1000/{}".format(frames[0]["delay"]), None) return ("1000/{}".format(frames[0]["delay"]), None)
if not self.uniform:
gcd = self._delay_gcd(frames) gcd = self._delay_gcd(frames)
if gcd >= 10: if gcd >= 10:
return (None, "1000/{}".format(gcd)) return (None, "1000/{}".format(gcd))

Loading…
Cancel
Save