1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[postprocessor:ugoira] add option for two-pass encoding

This commit is contained in:
Mike Fährmann 2018-06-20 18:48:10 +02:00
parent a9e276bc37
commit 0c1c4557dd
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 26 additions and 4 deletions

View File

@ -865,6 +865,17 @@ Default ``"ffmpeg"``
Description Location of the ``ffmpeg`` (or ``avconv``) executable to use.
=========== =====
ugoira.ffmpeg-twopass
---------------------
=========== =====
Type ``bool``
Default ``False``
Description Enable Two-Pass encoding.
It is recommended to explicitly set a container format with
``-f <fmt>`` using `ugoira.ffmpeg-args`_ when using this option.
=========== =====
ugoira.keep-files
-----------------
=========== =====

View File

@ -13,6 +13,7 @@ from .. import util
import subprocess
import tempfile
import zipfile
import os
class UgoiraPP(PostProcessor):
@ -20,10 +21,13 @@ class UgoiraPP(PostProcessor):
def __init__(self, pathfmt, options):
PostProcessor.__init__(self)
self.extension = options.get("extension") or "webm"
self.ffmpeg = options.get("ffmpeg-location") or "ffmpeg"
self.args = options.get("ffmpeg-args")
self.twopass = options.get("ffmpeg-twopass")
self.delete = not options.get("keep-files", False)
ffmpeg = options.get("ffmpeg-location")
self.ffmpeg = util.expand_path(ffmpeg) if ffmpeg else "ffmpeg"
def run(self, pathfmt):
if (pathfmt.keywords["extension"] != "zip" or
"frames" not in pathfmt.keywords):
@ -53,11 +57,18 @@ class UgoiraPP(PostProcessor):
# invoke ffmpeg
pathfmt.set_extension(self.extension)
args = [util.expand_path(self.ffmpeg), "-i", ffconcat]
args = [self.ffmpeg, "-i", ffconcat]
if self.args:
args += self.args
args.append(pathfmt.realpath)
subprocess.Popen(args).wait()
if self.twopass:
log = tempdir + "/ffmpeg2pass"
null = "NUL" if os.name == "nt" else "/dev/null"
args += ["-passlogfile", log, "-pass"]
subprocess.Popen(args + ["1", "-y", null]).wait()
subprocess.Popen(args + ["2", pathfmt.realpath]).wait()
else:
args.append(pathfmt.realpath)
subprocess.Popen(args).wait()
if self.delete:
pathfmt.delete = True