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:
parent
a9e276bc37
commit
0c1c4557dd
@ -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
|
||||
-----------------
|
||||
=========== =====
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user