Validate --merge-output-format

Closes #4489
This commit is contained in:
pukkandan 2022-07-31 01:35:56 +05:30
parent 8dc5930511
commit 4f04be6add
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
4 changed files with 11 additions and 7 deletions

View file

@ -859,10 +859,10 @@ ## Video Format Options:
downloadable downloadable
-F, --list-formats List available formats of each video. -F, --list-formats List available formats of each video.
Simulate unless --no-simulate is used Simulate unless --no-simulate is used
--merge-output-format FORMAT If a merge is required (e.g. --merge-output-format FORMAT Container to use when merging formats (e.g.
bestvideo+bestaudio), output to given bestvideo+bestaudio). Ignored if no merge is
container format. One of mkv, mp4, ogg, required. (currently supported: avi, flv,
webm, flv. Ignored if no merge is required mkv, mov, mp4, webm)
## Subtitle Options: ## Subtitle Options:
--write-subs Write subtitle file --write-subs Write subtitle file

View file

@ -20,6 +20,7 @@
from .options import parseOpts from .options import parseOpts
from .postprocessor import ( from .postprocessor import (
FFmpegExtractAudioPP, FFmpegExtractAudioPP,
FFmpegMergerPP,
FFmpegPostProcessor, FFmpegPostProcessor,
FFmpegSubtitlesConvertorPP, FFmpegSubtitlesConvertorPP,
FFmpegThumbnailsConvertorPP, FFmpegThumbnailsConvertorPP,
@ -223,6 +224,7 @@ def validate_minmax(min_val, max_val, min_name, max_name=None):
validate_regex('format sorting', f, InfoExtractor.FormatSort.regex) validate_regex('format sorting', f, InfoExtractor.FormatSort.regex)
# Postprocessor formats # Postprocessor formats
validate_in('merge output format', opts.merge_output_format, FFmpegMergerPP.SUPPORTED_EXTS)
validate_regex('audio format', opts.audioformat, FFmpegExtractAudioPP.FORMAT_RE) validate_regex('audio format', opts.audioformat, FFmpegExtractAudioPP.FORMAT_RE)
validate_in('subtitle format', opts.convertsubtitles, FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS) validate_in('subtitle format', opts.convertsubtitles, FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS)
validate_regex('thumbnail format', opts.convertthumbnails, FFmpegThumbnailsConvertorPP.FORMAT_RE) validate_regex('thumbnail format', opts.convertthumbnails, FFmpegThumbnailsConvertorPP.FORMAT_RE)

View file

@ -13,6 +13,7 @@
from .downloader.external import list_external_downloaders from .downloader.external import list_external_downloaders
from .postprocessor import ( from .postprocessor import (
FFmpegExtractAudioPP, FFmpegExtractAudioPP,
FFmpegMergerPP,
FFmpegSubtitlesConvertorPP, FFmpegSubtitlesConvertorPP,
FFmpegThumbnailsConvertorPP, FFmpegThumbnailsConvertorPP,
FFmpegVideoRemuxerPP, FFmpegVideoRemuxerPP,
@ -781,9 +782,8 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs):
'--merge-output-format', '--merge-output-format',
action='store', dest='merge_output_format', metavar='FORMAT', default=None, action='store', dest='merge_output_format', metavar='FORMAT', default=None,
help=( help=(
'If a merge is required (e.g. bestvideo+bestaudio), ' 'Container to use when merging formats (e.g. bestvideo+bestaudio). Ignored if no merge is required. '
'output to given container format. One of mkv, mp4, ogg, webm, flv. ' f'(currently supported: {", ".join(sorted(FFmpegMergerPP.SUPPORTED_EXTS))})'))
'Ignored if no merge is required'))
video_format.add_option( video_format.add_option(
'--allow-unplayable-formats', '--allow-unplayable-formats',
action='store_true', dest='allow_unplayable_formats', default=False, action='store_true', dest='allow_unplayable_formats', default=False,

View file

@ -801,6 +801,8 @@ def _get_infojson_opts(self, info, infofn):
class FFmpegMergerPP(FFmpegPostProcessor): class FFmpegMergerPP(FFmpegPostProcessor):
SUPPORTED_EXTS = MEDIA_EXTENSIONS.common_video
@PostProcessor._restrict_to(images=False) @PostProcessor._restrict_to(images=False)
def run(self, info): def run(self, info):
filename = info['filepath'] filename = info['filepath']