[pp:ugoira] add '"framerate": "uniform"' (#4421)
This commit is contained in:
@@ -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,9 +288,10 @@ 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)
|
||||||
|
|
||||||
gcd = self._delay_gcd(frames)
|
if not self.uniform:
|
||||||
if gcd >= 10:
|
gcd = self._delay_gcd(frames)
|
||||||
return (None, "1000/{}".format(gcd))
|
if gcd >= 10:
|
||||||
|
return (None, "1000/{}".format(gcd))
|
||||||
|
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user