1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-08-15 08:58:28 +00:00

return container and block merging

Authored by: bashonly
This commit is contained in:
bashonly 2025-07-18 13:40:07 -05:00
parent 9a221819d4
commit 19ed787130
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0
3 changed files with 15 additions and 3 deletions

View File

@ -3452,6 +3452,7 @@ def correct_ext(filename, ext=new_ext):
merger = FFmpegMergerPP(self)
downloaded = []
should_merge = True
if dl_filename is not None:
self.report_file_already_downloaded(dl_filename)
elif fd:
@ -3469,12 +3470,20 @@ def correct_ext(filename, ext=new_ext):
'You have requested merging of multiple formats '
'while also allowing unplayable formats to be downloaded. '
'The formats won\'t be merged to prevent data corruption.')
should_merge = False
elif not merger.available:
msg = 'You have requested merging of multiple formats but ffmpeg is not installed'
if not self.params.get('ignoreerrors'):
self.report_error(f'{msg}. Aborting due to --abort-on-error')
return
self.report_warning(f'{msg}. The formats won\'t be merged')
should_merge = False
elif any(f.get('container') == 'iamf' for f in info_dict['requested_formats']):
self.report_warning(
'You have requested merging of multiple formats '
'but one of the formats is an IAMF audio format. '
'The formats won\'t be merged to prevent data loss.')
should_merge = False
if temp_filename == '-':
reason = ('using a downloader other than ffmpeg' if FFmpegFD.can_merge_formats(info_dict, self.params)
@ -3500,7 +3509,7 @@ def correct_ext(filename, ext=new_ext):
info_dict['__real_download'] = info_dict['__real_download'] or real_download
success = success and partial_success
if downloaded and merger.available and not self.params.get('allow_unplayable_formats'):
if downloaded and should_merge:
info_dict['__postprocessors'].append(merger)
info_dict['__files_to_merge'] = downloaded
# Even if there were no downloads, it is being merged only now

View File

@ -3489,7 +3489,7 @@ def build_fragments(f):
itags[itag].add(('https', dct.get('language')))
stream_ids.append(stream_id)
single_stream = 'none' in (dct.get('acodec'), dct.get('vcodec'))
if single_stream and dct.get('ext'):
if single_stream and dct.get('ext') and not dct.get('container'):
dct['container'] = dct['ext'] + '_dash'
if (all_formats or 'dashy' in format_types) and dct['filesize']:

View File

@ -3024,7 +3024,7 @@ def parse_codecs(codecs_str):
return {}
split_codecs = list(filter(None, map(
str.strip, codecs_str.strip().strip(',').split(','))))
vcodec, acodec, scodec, hdr = None, None, None, None
vcodec, acodec, scodec, hdr, container = None, None, None, None, None
for full_codec in split_codecs:
full_codec = re.sub(r'^([^.]+)', lambda m: m.group(1).lower(), full_codec)
parts = re.sub(r'0+(?=\d)', '', full_codec).split('.')
@ -3042,6 +3042,8 @@ def parse_codecs(codecs_str):
elif parts[0] in ('flac', 'mp4a', 'opus', 'vorbis', 'mp3', 'aac', 'ac-4',
'ac-3', 'ec-3', 'eac3', 'dtsc', 'dtse', 'dtsh', 'dtsl', 'iamf'):
acodec = acodec or full_codec
if parts[0] == 'iamf':
container = 'iamf'
elif parts[0] in ('stpp', 'wvtt'):
scodec = scodec or full_codec
else:
@ -3052,6 +3054,7 @@ def parse_codecs(codecs_str):
'acodec': acodec or 'none',
'dynamic_range': hdr,
**({'scodec': scodec} if scodec is not None else {}),
**({'container': container} if container is not None else {}),
}
elif len(split_codecs) == 2:
return {