mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
replace '--ugoira-conv' etc with a general '--ugoira'
update --ugoira webm to use the same FFmpeg args as Danbooru --ugoira-conv -> --ugoira vp8 --ugoira-conv-lossless -> --ugoira vp9-lossless --ugoira-conv-copy -> --ugoira copy (--ugoira-conv and co still work as before, but --help now lists only --ugoira)
This commit is contained in:
parent
97357e65ee
commit
168331d147
@ -120,11 +120,9 @@
|
|||||||
## Post-processing Options:
|
## Post-processing Options:
|
||||||
--zip Store downloaded files in a ZIP archive
|
--zip Store downloaded files in a ZIP archive
|
||||||
--cbz Store downloaded files in a CBZ archive
|
--cbz Store downloaded files in a CBZ archive
|
||||||
--ugoira-conv Convert Pixiv Ugoira to WebM (requires FFmpeg)
|
--ugoira FORMAT Convert Pixiv Ugoira to FORMAT using FFmpeg.
|
||||||
--ugoira-conv-lossless Convert Pixiv Ugoira to WebM in VP9 lossless
|
Supported formats are 'webm', 'mp4', 'gif',
|
||||||
mode
|
'vp8', 'vp9', 'vp9-lossless', 'copy'.
|
||||||
--ugoira-conv-copy Convert Pixiv Ugoira to MKV without re-encoding
|
|
||||||
any frames
|
|
||||||
--write-metadata Write metadata to separate JSON files
|
--write-metadata Write metadata to separate JSON files
|
||||||
--write-info-json Write gallery metadata to a info.json file
|
--write-info-json Write gallery metadata to a info.json file
|
||||||
--write-tags Write image tags to separate text files
|
--write-tags Write image tags to separate text files
|
||||||
|
@ -66,7 +66,7 @@ class InputfileAction(argparse.Action):
|
|||||||
|
|
||||||
|
|
||||||
class MtimeAction(argparse.Action):
|
class MtimeAction(argparse.Action):
|
||||||
"""Configure mtime post processor"""
|
"""Configure mtime post processors"""
|
||||||
def __call__(self, parser, namespace, value, option_string=None):
|
def __call__(self, parser, namespace, value, option_string=None):
|
||||||
namespace.postprocessors.append({
|
namespace.postprocessors.append({
|
||||||
"name": "mtime",
|
"name": "mtime",
|
||||||
@ -74,6 +74,64 @@ class MtimeAction(argparse.Action):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class UgoiraAction(argparse.Action):
|
||||||
|
"""Configure ugoira post processors"""
|
||||||
|
def __call__(self, parser, namespace, value, option_string=None):
|
||||||
|
if self.const:
|
||||||
|
value = self.const
|
||||||
|
else:
|
||||||
|
value = value.strip().lower()
|
||||||
|
|
||||||
|
if value in ("webm", "vp9"):
|
||||||
|
pp = {
|
||||||
|
"extension" : "webm",
|
||||||
|
"ffmpeg-args" : ("-c:v", "libvpx-vp9",
|
||||||
|
"-crf", "12",
|
||||||
|
"-b:v", "0", "-an"),
|
||||||
|
}
|
||||||
|
elif value == "vp9-lossless":
|
||||||
|
pp = {
|
||||||
|
"extension" : "webm",
|
||||||
|
"ffmpeg-args" : ("-c:v", "libvpx-vp9",
|
||||||
|
"-lossless", "1",
|
||||||
|
"-pix_fmt", "yuv420p", "-an"),
|
||||||
|
}
|
||||||
|
elif value == "vp8":
|
||||||
|
pp = {
|
||||||
|
"extension" : "webm",
|
||||||
|
"ffmpeg-args" : ("-c:v", "libvpx",
|
||||||
|
"-crf", "4",
|
||||||
|
"-b:v", "5000k", "-an"),
|
||||||
|
}
|
||||||
|
elif value == "mp4":
|
||||||
|
pp = {
|
||||||
|
"extension" : "mp4",
|
||||||
|
"ffmpeg-args" : ("-c:v", "libx264", "-an", "-b:v", "5M"),
|
||||||
|
"libx264-prevent-odd": True,
|
||||||
|
}
|
||||||
|
elif value == "gif":
|
||||||
|
pp = {
|
||||||
|
"extension" : "gif",
|
||||||
|
"ffmpeg-args" : ("-filter_complex", "[0:v] split [a][b];"
|
||||||
|
"[a] palettegen [p];[b][p] paletteuse"),
|
||||||
|
"repeat-last-frame": False,
|
||||||
|
}
|
||||||
|
elif value in ("mkv", "copy"):
|
||||||
|
pp = {
|
||||||
|
"extension" : "mkv",
|
||||||
|
"ffmpeg-args" : ("-c:v", "copy"),
|
||||||
|
"repeat-last-frame": False,
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
parser.error("Unsupported Ugoira format '{}'".format(value))
|
||||||
|
|
||||||
|
pp["name"] = "ugoira"
|
||||||
|
pp["whitelist"] = ("pixiv", "danbooru")
|
||||||
|
|
||||||
|
namespace.options.append(((), "ugoira", True))
|
||||||
|
namespace.postprocessors.append(pp)
|
||||||
|
|
||||||
|
|
||||||
class Formatter(argparse.HelpFormatter):
|
class Formatter(argparse.HelpFormatter):
|
||||||
"""Custom HelpFormatter class to customize help output"""
|
"""Custom HelpFormatter class to customize help output"""
|
||||||
def __init__(self, prog):
|
def __init__(self, prog):
|
||||||
@ -487,38 +545,28 @@ def build_parser():
|
|||||||
},
|
},
|
||||||
help="Store downloaded files in a CBZ archive",
|
help="Store downloaded files in a CBZ archive",
|
||||||
)
|
)
|
||||||
|
postprocessor.add_argument(
|
||||||
|
"--ugoira",
|
||||||
|
dest="postprocessors", metavar="FORMAT", action=UgoiraAction,
|
||||||
|
help=("Convert Pixiv Ugoira to FORMAT using FFmpeg. "
|
||||||
|
"Supported formats are 'webm', 'mp4', 'gif', "
|
||||||
|
"'vp8', 'vp9', 'vp9-lossless', 'copy'."),
|
||||||
|
)
|
||||||
postprocessor.add_argument(
|
postprocessor.add_argument(
|
||||||
"--ugoira-conv",
|
"--ugoira-conv",
|
||||||
dest="postprocessors", action="append_const", const={
|
dest="postprocessors", nargs=0, action=UgoiraAction, const="vp8",
|
||||||
"name" : "ugoira",
|
help=argparse.SUPPRESS,
|
||||||
"ffmpeg-args" : ("-c:v", "libvpx", "-crf", "4", "-b:v", "5000k"),
|
|
||||||
"ffmpeg-twopass": True,
|
|
||||||
"whitelist" : ("pixiv", "danbooru"),
|
|
||||||
},
|
|
||||||
help="Convert Pixiv Ugoira to WebM (requires FFmpeg)",
|
|
||||||
)
|
)
|
||||||
postprocessor.add_argument(
|
postprocessor.add_argument(
|
||||||
"--ugoira-conv-lossless",
|
"--ugoira-conv-lossless",
|
||||||
dest="postprocessors", action="append_const", const={
|
dest="postprocessors", nargs=0, action=UgoiraAction,
|
||||||
"name" : "ugoira",
|
const="vp9-lossless",
|
||||||
"ffmpeg-args" : ("-c:v", "libvpx-vp9", "-lossless", "1",
|
help=argparse.SUPPRESS,
|
||||||
"-pix_fmt", "yuv420p"),
|
|
||||||
"ffmpeg-twopass": False,
|
|
||||||
"whitelist" : ("pixiv", "danbooru"),
|
|
||||||
},
|
|
||||||
help="Convert Pixiv Ugoira to WebM in VP9 lossless mode",
|
|
||||||
)
|
)
|
||||||
postprocessor.add_argument(
|
postprocessor.add_argument(
|
||||||
"--ugoira-conv-copy",
|
"--ugoira-conv-copy",
|
||||||
dest="postprocessors", action="append_const", const={
|
dest="postprocessors", nargs=0, action=UgoiraAction, const="copy",
|
||||||
"name" : "ugoira",
|
help=argparse.SUPPRESS,
|
||||||
"extension" : "mkv",
|
|
||||||
"ffmpeg-args" : ("-c:v", "copy"),
|
|
||||||
"ffmpeg-twopass" : False,
|
|
||||||
"repeat-last-frame": False,
|
|
||||||
"whitelist" : ("pixiv", "danbooru"),
|
|
||||||
},
|
|
||||||
help="Convert Pixiv Ugoira to MKV without re-encoding any frames",
|
|
||||||
)
|
)
|
||||||
postprocessor.add_argument(
|
postprocessor.add_argument(
|
||||||
"--write-metadata",
|
"--write-metadata",
|
||||||
|
Loading…
Reference in New Issue
Block a user