Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically select m4a or webm audio depending on the video file #26492

Open
SamLevin1999 opened this issue Sep 1, 2020 · 4 comments
Open

Automatically select m4a or webm audio depending on the video file #26492

SamLevin1999 opened this issue Sep 1, 2020 · 4 comments
Labels

Comments

@SamLevin1999
Copy link

@SamLevin1999 SamLevin1999 commented Sep 1, 2020

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

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

[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)

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 ?

@SamLevin1999
Copy link
Author

@SamLevin1999 SamLevin1999 commented Sep 1, 2020

After reading the FAQ 5-6 times i've came up with this line
-f bestvideo[height<=2160][ext=mp4]+bestaudio[ext=m4a]

now it always downloads files in .mp4 format. but i'm okay with that.
It would still be great if someone could answer the question...

@Wogol
Copy link

@Wogol Wogol commented Sep 1, 2020

This can maybe be interesting?
Choose best video and audio, mix webm and mp4.

youtube-dl -f bestvideo+bestaudio --merge-output-format mkv [http_link]

Or this script?
https://askubuntu.com/a/965815

@Thirumalai
Copy link

@Thirumalai Thirumalai commented Sep 1, 2020

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.

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 ?

The problem is with the bestvideo[height<=2160]. As webm video has higher bitrate, it's getting selected with m4a audio. However, mp4 container doesn't support vp9 codec. So, mkv will be automatically used.

After reading the FAQ 5-6 times i've came up with this line
-f bestvideo[height<=2160][ext=mp4]+bestaudio[ext=m4a]

As you are explicitly mentioning the video extension here, it will pick the h.264 (i.e avc) video. As mp4 container supports both h.264 video and aac audio codecs, it will be used.

@Thirumalai
Copy link

@Thirumalai Thirumalai commented Sep 1, 2020

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 ?

I don't think so.
However, the following can be used to achieve the same.

-f 'bestvideo[height<=2160][ext=mp4]+bestaudio[ext=m4a]/bestvideo[height<=2160][ext=webm]+bestaudio[ext=webm]'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.