[postprocessor:ugoira] improve libx264 detection
This commit is contained in:
@@ -958,14 +958,13 @@ ugoira.libx264-prevent-odd
|
|||||||
Type ``bool``
|
Type ``bool``
|
||||||
Default ``true``
|
Default ``true``
|
||||||
Description Prevent ``"width/height not divisible by 2"`` errors
|
Description Prevent ``"width/height not divisible by 2"`` errors
|
||||||
when presumably using a ``libx264`` encoder
|
when using ``libx264`` or ``libx265`` encoders
|
||||||
by applying a simple cropping filter. See this `Stack Overflow
|
by applying a simple cropping filter. See this `Stack Overflow
|
||||||
thread <https://stackoverflow.com/questions/20847674>`__
|
thread <https://stackoverflow.com/questions/20847674>`__
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
If the `filename extension`__ is set to ``mp4`` or ``mkv``,
|
This option, when ``libx264/5`` is used, automatically
|
||||||
this option effectively adds
|
adds ``["-vf", "crop=iw-mod(iw\\,2):ih-mod(ih\\,2)"]``
|
||||||
``["-vf", "crop=iw-mod(iw\\,2):ih-mod(ih\\,2)"]``
|
|
||||||
to the list of FFmpeg command-line arguments
|
to the list of FFmpeg command-line arguments
|
||||||
to reduce an odd width/height by 1 pixel and make them even.
|
to reduce an odd width/height by 1 pixel and make them even.
|
||||||
=========== =====
|
=========== =====
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class UgoiraPP(PostProcessor):
|
|||||||
def __init__(self, pathfmt, options):
|
def __init__(self, pathfmt, options):
|
||||||
PostProcessor.__init__(self)
|
PostProcessor.__init__(self)
|
||||||
self.extension = options.get("extension") or "webm"
|
self.extension = options.get("extension") or "webm"
|
||||||
self.args = options.get("ffmpeg-args")
|
self.args = options.get("ffmpeg-args") or ()
|
||||||
self.twopass = options.get("ffmpeg-twopass", False)
|
self.twopass = options.get("ffmpeg-twopass", False)
|
||||||
self.output = options.get("ffmpeg-output", True)
|
self.output = options.get("ffmpeg-output", True)
|
||||||
self.delete = not options.get("keep-files", False)
|
self.delete = not options.get("keep-files", False)
|
||||||
@@ -34,9 +34,20 @@ class UgoiraPP(PostProcessor):
|
|||||||
if rate != "auto":
|
if rate != "auto":
|
||||||
self.calculate_framerate = lambda _: (None, rate)
|
self.calculate_framerate = lambda _: (None, rate)
|
||||||
|
|
||||||
self.prevent_odd = (
|
if options.get("libx264-prevent-odd", True):
|
||||||
options.get("libx264-prevent-odd", True) and
|
# get last video-codec argument
|
||||||
self.extension.lower() in ("mp4", "mkv"))
|
vcodec = None
|
||||||
|
for index, arg in enumerate(self.args):
|
||||||
|
arg, _, stream = arg.partition(":")
|
||||||
|
if arg == "-vcodec" or arg in ("-c", "-codec") and (
|
||||||
|
not stream or stream.partition(":")[0] in ("v", "V")):
|
||||||
|
vcodec = self.args[index + 1]
|
||||||
|
# use filter if libx264/5 is explicitly or implicitly used
|
||||||
|
self.prevent_odd = (
|
||||||
|
vcodec in ("libx264", "libx265") or
|
||||||
|
not vcodec and self.extension.lower() in ("mp4", "mkv"))
|
||||||
|
else:
|
||||||
|
self.prevent_odd = False
|
||||||
|
|
||||||
def run(self, pathfmt):
|
def run(self, pathfmt):
|
||||||
if pathfmt.keywords["extension"] != "zip":
|
if pathfmt.keywords["extension"] != "zip":
|
||||||
|
|||||||
Reference in New Issue
Block a user