From 4f04be6add6133d103b4c671cec02128a8a0f16e Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 31 Jul 2022 01:35:56 +0530 Subject: [PATCH] Validate `--merge-output-format` Closes #4489 --- README.md | 8 ++++---- yt_dlp/__init__.py | 2 ++ yt_dlp/options.py | 6 +++--- yt_dlp/postprocessor/ffmpeg.py | 2 ++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 607e92989..7b416f39a 100644 --- a/README.md +++ b/README.md @@ -859,10 +859,10 @@ You can also fork the project on github and run your fork's [build workflow](.gi downloadable -F, --list-formats List available formats of each video. Simulate unless --no-simulate is used - --merge-output-format FORMAT If a merge is required (e.g. - bestvideo+bestaudio), output to given - container format. One of mkv, mp4, ogg, - webm, flv. Ignored if no merge is required + --merge-output-format FORMAT Container to use when merging formats (e.g. + bestvideo+bestaudio). Ignored if no merge is + required. (currently supported: avi, flv, + mkv, mov, mp4, webm) ## Subtitle Options: --write-subs Write subtitle file diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 0bff4e7c8..c106c0ae7 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -20,6 +20,7 @@ from .extractor.common import InfoExtractor from .options import parseOpts from .postprocessor import ( FFmpegExtractAudioPP, + FFmpegMergerPP, FFmpegPostProcessor, FFmpegSubtitlesConvertorPP, FFmpegThumbnailsConvertorPP, @@ -223,6 +224,7 @@ def validate_options(opts): validate_regex('format sorting', f, InfoExtractor.FormatSort.regex) # Postprocessor formats + validate_in('merge output format', opts.merge_output_format, FFmpegMergerPP.SUPPORTED_EXTS) validate_regex('audio format', opts.audioformat, FFmpegExtractAudioPP.FORMAT_RE) validate_in('subtitle format', opts.convertsubtitles, FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS) validate_regex('thumbnail format', opts.convertthumbnails, FFmpegThumbnailsConvertorPP.FORMAT_RE) diff --git a/yt_dlp/options.py b/yt_dlp/options.py index 43d1af96d..be53ad3e3 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -13,6 +13,7 @@ from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS from .downloader.external import list_external_downloaders from .postprocessor import ( FFmpegExtractAudioPP, + FFmpegMergerPP, FFmpegSubtitlesConvertorPP, FFmpegThumbnailsConvertorPP, FFmpegVideoRemuxerPP, @@ -781,9 +782,8 @@ def create_parser(): '--merge-output-format', action='store', dest='merge_output_format', metavar='FORMAT', default=None, help=( - 'If a merge is required (e.g. bestvideo+bestaudio), ' - 'output to given container format. One of mkv, mp4, ogg, webm, flv. ' - 'Ignored if no merge is required')) + 'Container to use when merging formats (e.g. bestvideo+bestaudio). Ignored if no merge is required. ' + f'(currently supported: {", ".join(sorted(FFmpegMergerPP.SUPPORTED_EXTS))})')) video_format.add_option( '--allow-unplayable-formats', action='store_true', dest='allow_unplayable_formats', default=False, diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index c4dc99fe8..f80838962 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -801,6 +801,8 @@ class FFmpegMetadataPP(FFmpegPostProcessor): class FFmpegMergerPP(FFmpegPostProcessor): + SUPPORTED_EXTS = MEDIA_EXTENSIONS.common_video + @PostProcessor._restrict_to(images=False) def run(self, info): filename = info['filepath']