Skip to content

Commit

Permalink
[pp:ugoira] extend 'ffmpeg-output' (#4421)
Browse files Browse the repository at this point in the history
- when setting this option to a string value,
  pass -hide-banner and -loglevel to FFmpeg
- change default to "error"
  • Loading branch information
mikf committed Aug 21, 2023
1 parent 8dceea3 commit 70bdf32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 9 additions & 3 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4872,11 +4872,17 @@ Description
ugoira.ffmpeg-output
--------------------
Type
``bool``
* ``bool``
* ``string``
Default
``true``
``"error"``
Description
Show FFmpeg output.
Controls FFmpeg output.

* ``true``: Enable FFmpeg output
* ``false``: Disable all FFmpeg output
* any ``string``: Pass ``-hide_banner`` and ``-loglevel``
with this value as argument to FFmpeg


ugoira.ffmpeg-twopass
Expand Down
14 changes: 10 additions & 4 deletions gallery_dl/postprocessor/ugoira.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright 2018-2022 Mike Fährmann
# Copyright 2018-2023 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
Expand Down Expand Up @@ -32,7 +32,7 @@ def __init__(self, job, options):
self.extension = options.get("extension") or "webm"
self.args = options.get("ffmpeg-args") or ()
self.twopass = options.get("ffmpeg-twopass", False)
self.output = options.get("ffmpeg-output", True)
self.output = options.get("ffmpeg-output", "error")
self.delete = not options.get("keep-files", False)
self.repeat = options.get("repeat-last-frame", True)
self.mtime = options.get("mtime", True)
Expand Down Expand Up @@ -81,6 +81,12 @@ def __init__(self, job, options):
else:
self.prevent_odd = False

self.args_pp = args = []
if isinstance(self.output, str):
args += ("-hide_banner", "-loglevel", self.output)
if self.prevent_odd:
args += ("-vf", "crop=iw-mod(iw\\,2):ih-mod(ih\\,2)")

job.register_hooks(
{"prepare": self.prepare, "file": self.convert}, options)

Expand Down Expand Up @@ -120,8 +126,8 @@ def convert(self, pathfmt):
pathfmt.build_path()

args = self._process(pathfmt, tempdir)
if self.prevent_odd:
args += ("-vf", "crop=iw-mod(iw\\,2):ih-mod(ih\\,2)")
if self.args_pp:
args += self.args_pp
if self.args:
args += self.args

Expand Down

0 comments on commit 70bdf32

Please sign in to comment.