Allow downloading DASH streams in any order
With this change, -f bestaudio+bestvideo will no longer display an error, but download the audio stream before downloading video. Both streams will be then merged as usual.
This commit is contained in:
parent
0a64aa7355
commit
4ac14d17f5
@ -1105,32 +1105,31 @@ class YoutubeDL(object):
|
|||||||
formats_info = (self.select_format(format_1, formats),
|
formats_info = (self.select_format(format_1, formats),
|
||||||
self.select_format(format_2, formats))
|
self.select_format(format_2, formats))
|
||||||
if all(formats_info):
|
if all(formats_info):
|
||||||
# The first format must contain the video and the
|
try:
|
||||||
# second the audio
|
vfmtinfo = [fmt for fmt in formats_info if fmt.get('vcodec') != 'none'][0]
|
||||||
if formats_info[0].get('vcodec') == 'none':
|
afmtinfo = [fmt for fmt in formats_info if fmt.get('acodec') != 'none'][0]
|
||||||
self.report_error('The first format must '
|
except IndexError:
|
||||||
'contain the video, try using '
|
self.report_error('You must specify a single video format and a single audio format')
|
||||||
'"-f %s+%s"' % (format_2, format_1))
|
|
||||||
return
|
return
|
||||||
output_ext = (
|
|
||||||
formats_info[0]['ext']
|
output_ext = self.params.get('merge_output_format')
|
||||||
if self.params.get('merge_output_format') is None
|
if output_ext is None:
|
||||||
else self.params['merge_output_format'])
|
output_ext = vfmtinfo['ext']
|
||||||
selected_format = {
|
selected_format = {
|
||||||
'requested_formats': formats_info,
|
'requested_formats': formats_info,
|
||||||
'format': '%s+%s' % (formats_info[0].get('format'),
|
'format': '%s+%s' % (vfmtinfo.get('format'),
|
||||||
formats_info[1].get('format')),
|
afmtinfo.get('format')),
|
||||||
'format_id': '%s+%s' % (formats_info[0].get('format_id'),
|
'format_id': '%s+%s' % (vfmtinfo.get('format_id'),
|
||||||
formats_info[1].get('format_id')),
|
afmtinfo.get('format_id')),
|
||||||
'width': formats_info[0].get('width'),
|
'width': vfmtinfo.get('width'),
|
||||||
'height': formats_info[0].get('height'),
|
'height': vfmtinfo.get('height'),
|
||||||
'resolution': formats_info[0].get('resolution'),
|
'resolution': vfmtinfo.get('resolution'),
|
||||||
'fps': formats_info[0].get('fps'),
|
'fps': vfmtinfo.get('fps'),
|
||||||
'vcodec': formats_info[0].get('vcodec'),
|
'vcodec': vfmtinfo.get('vcodec'),
|
||||||
'vbr': formats_info[0].get('vbr'),
|
'vbr': vfmtinfo.get('vbr'),
|
||||||
'stretched_ratio': formats_info[0].get('stretched_ratio'),
|
'stretched_ratio': vfmtinfo.get('stretched_ratio'),
|
||||||
'acodec': formats_info[1].get('acodec'),
|
'acodec': afmtinfo.get('acodec'),
|
||||||
'abr': formats_info[1].get('abr'),
|
'abr': afmtinfo.get('abr'),
|
||||||
'ext': output_ext,
|
'ext': output_ext,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
@ -585,7 +585,12 @@ class FFmpegMergerPP(FFmpegPostProcessor):
|
|||||||
def run(self, info):
|
def run(self, info):
|
||||||
filename = info['filepath']
|
filename = info['filepath']
|
||||||
temp_filename = prepend_extension(filename, 'temp')
|
temp_filename = prepend_extension(filename, 'temp')
|
||||||
args = ['-c', 'copy', '-map', '0:v:0', '-map', '1:a:0']
|
args = ['-c', 'copy']
|
||||||
|
for (i, fmt) in enumerate(info['requested_formats']):
|
||||||
|
if fmt.get('acodec') != 'none':
|
||||||
|
args.extend(['-map', '%u:a:0' % (i)])
|
||||||
|
if fmt.get('vcodec') != 'none':
|
||||||
|
args.extend(['-map', '%u:v:0' % (i)])
|
||||||
self._downloader.to_screen('[ffmpeg] Merging formats into "%s"' % filename)
|
self._downloader.to_screen('[ffmpeg] Merging formats into "%s"' % filename)
|
||||||
self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
|
self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
|
||||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user