Repository: youtube-dl
Issue: Automatically select m4a or webm audio depending on the video file
Labels: question

<!--

######################################################################
  WARNING!
  IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE
######################################################################

-->


## Checklist

<!--
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
- Look through the README (http://yt-dl.org/readme) and FAQ (http://yt-dl.org/faq) for similar questions
- Search the bugtracker for similar questions: http://yt-dl.org/search-issues
- Finally, put x into all relevant boxes (like this [x])
-->

- [x] I'm asking a question
- [x] I've looked through the README and FAQ for similar questions
- [x] I've searched the bugtracker for similar questions including closed ones


## Question

<!--
Ask your question in an arbitrary form. Please make sure it's worded well enough to be understood, see https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient.
-->
Hi,
I tried downloading this video in 2160p [4K] format and I used `-f bestvideo[height<=2160]+bestaudio[ext=m4a]` but it ended up in being an **.mkv** file.

Available formats for video. URL : https://www.youtube.com/watch?v=1La4QzGeaaQ

<pre>[youtube] 1La4QzGeaaQ: Downloading webpage
[info] Available formats for 1La4QzGeaaQ:
format code  extension  resolution note
249          webm       audio only tiny   58k , opus @ 50k (48000Hz), 2.01MiB
250          webm       audio only tiny   78k , opus @ 70k (48000Hz), 2.68MiB
140          m4a        audio only tiny  130k , m4a_dash container, mp4a.40.2@128k (44100Hz), 5.21MiB
251          webm       audio only tiny  150k , opus @160k (48000Hz), 5.29MiB
394          mp4        256x144    144p   77k , av01.0.00M.10.0.110.09.16.09.0, 30fps, video only, 2.60MiB
278          webm       256x144    144p   98k , webm container, vp9, 30fps, video only, 3.65MiB
160          mp4        256x144    144p  111k , avc1.4d400c, 30fps, video only, 2.67MiB
395          mp4        426x240    240p  170k , av01.0.00M.10.0.110.09.16.09.0, 30fps, video only, 5.03MiB
242          webm       426x240    240p  228k , vp9, 30fps, video only, 7.59MiB
133          mp4        426x240    240p  245k , avc1.4d4015, 30fps, video only, 5.69MiB
330          webm       256x144    144p60 HDR  245k , vp9.2, 60fps, video only, 8.72MiB
396          mp4        640x360    360p  395k , av01.0.01M.10.0.110.09.16.09.0, 30fps, video only, 10.42MiB
243          webm       640x360    360p  422k , vp9, 30fps, video only, 14.19MiB
331          webm       426x240    240p60 HDR  517k , vp9.2, 60fps, video only, 18.91MiB
134          mp4        640x360    360p  633k , avc1.4d401e, 30fps, video only, 17.17MiB
397          mp4        854x480    480p  734k , av01.0.04M.10.0.110.09.16.09.0, 30fps, video only, 19.56MiB
244          webm       854x480    480p  785k , vp9, 30fps, video only, 26.42MiB
332          webm       640x360    360p60 HDR 1064k , vp9.2, 60fps, video only, 40.80MiB
135          mp4        854x480    480p 1351k , avc1.4d401f, 30fps, video only, 35.59MiB
247          webm       1280x720   720p 1588k , vp9, 30fps, video only, 53.74MiB
333          webm       854x480    480p60 HDR 1988k , vp9.2, 60fps, video only, 77.26MiB
398          mp4        1280x720   720p60 2088k , av01.0.08M.10.0.110.09.16.09.0, 60fps, video only, 58.59MiB
302          webm       1280x720   720p60 2667k , vp9, 60fps, video only, 89.04MiB
136          mp4        1280x720   720p 2698k , avc1.4d401f, 30fps, video only, 70.39MiB
248          webm       1920x1080  1080p 2772k , vp9, 30fps, video only, 94.90MiB
399          mp4        1920x1080  1080p60 3771k , av01.0.09M.10.0.110.09.16.09.0, 60fps, video only, 111.45MiB
298          mp4        1280x720   720p60 4201k , avc1.4d4020, 60fps, video only, 115.83MiB
303          webm       1920x1080  1080p60 4486k , vp9, 60fps, video only, 154.48MiB
334          webm       1280x720   720p60 HDR 4529k , vp9.2, 60fps, video only, 176.99MiB
137          mp4        1920x1080  1080p 5065k , avc1.640028, 30fps, video only, 130.39MiB
335          webm       1920x1080  1080p60 HDR 6923k , vp9.2, 60fps, video only, 271.72MiB
299          mp4        1920x1080  1080p60 7007k , avc1.64002a, 60fps, video only, 204.42MiB
400          mp4        2560x1440  1440p60 8717k , av01.0.12M.10.0.110.09.16.09.0, 60fps, video only, 258.85MiB
271          webm       2560x1440  1440p 8977k , vp9, 30fps, video only, 297.43MiB
308          webm       2560x1440  1440p60 13368k , vp9, 60fps, video only, 448.85MiB
336          webm       2560x1440  1440p60 HDR 16746k , vp9.2, 60fps, video only, 651.85MiB
401          mp4        3840x2160  2160p60 17866k , av01.0.13M.10.0.110.09.16.09.0, 60fps, video only, 523.08MiB
313          webm       3840x2160  2160p 17965k , vp9, 30fps, video only, 644.01MiB
315          webm       3840x2160  2160p60 26684k , vp9, 60fps, video only, 988.10MiB
337          webm       3840x2160  2160p60 HDR 30553k , vp9.2, 60fps, video only, 1.13GiB
571          mp4        7680x4320  4320p60 35978k , av01.0.17M.10.0.110.09.16.09.0, 60fps, video only, 1003.95MiB
18           mp4        640x360    360p  667k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 26.87MiB
22           mp4        1280x720   720p 1877k , avc1.64001F, 30fps, mp4a.40.2@192k (44100Hz) (best)</pre>

Then I tried the following commands:
`bestvideo[height<=2160]+bestaudio[ext=m4a]/bestaudio[ext=webm]`
`bestvideo[height<=2160]+bestaudio[ext=m4a]/best[ext=webm]`
`bestvideo[height<=2160]+bestaudio[ext=m4a]/bestvideo[height<=2160]+bestaudio[ext=webm]`

but none of them worked, is it possible for youtube-dl to automatically select m4a when video file is mp4 and webm audio file for webm video ? I have read the FAQ section for format selection but still can't seem to figure it out. Is this feature available ?