Skip to content

Commit

Permalink
Infer acodec for single-codec containers
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan committed Mar 31, 2024
1 parent 50c2935 commit 86a9720
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/test_YoutubeDL.py
Expand Up @@ -183,7 +183,7 @@ def test_format_selection_audio_exts(self):
]

info_dict = _make_result(formats)
ydl = YDL({'format': 'best'})
ydl = YDL({'format': 'best', 'format_sort': ['abr', 'ext']})
ydl.sort_formats(info_dict)
ydl.process_ie_result(copy.deepcopy(info_dict))
downloaded = ydl.downloaded_info_dicts[0]
Expand All @@ -195,7 +195,7 @@ def test_format_selection_audio_exts(self):
downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], 'mp3-64')

ydl = YDL({'prefer_free_formats': True})
ydl = YDL({'prefer_free_formats': True, 'format_sort': ['abr', 'ext']})
ydl.sort_formats(info_dict)
ydl.process_ie_result(copy.deepcopy(info_dict))
downloaded = ydl.downloaded_info_dicts[0]
Expand Down
3 changes: 3 additions & 0 deletions yt_dlp/YoutubeDL.py
Expand Up @@ -2813,6 +2813,9 @@ def is_wellformed(f):
format['url'] = sanitize_url(format['url'])
if format.get('ext') is None:
format['ext'] = determine_ext(format['url']).lower()
if format['ext'] in ('aac', 'opus', 'mp3', 'flac', 'vorbis'):
if format.get('acodec') is None:
format['acodec'] = format['ext']
if format.get('protocol') is None:
format['protocol'] = determine_protocol(format)
if format.get('resolution') is None:
Expand Down

0 comments on commit 86a9720

Please sign in to comment.