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

download biggest file size #26450

Open
3 tasks done
gitfirl opened this issue Aug 27, 2020 · 3 comments · Fixed by pukkandan/youtube-dl#5
Open
3 tasks done

download biggest file size #26450

gitfirl opened this issue Aug 27, 2020 · 3 comments · Fixed by pukkandan/youtube-dl#5
Labels

Comments

@gitfirl
Copy link

gitfirl commented Aug 27, 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

How can I make youtube-dl automatically pick the file with the biggest size regardless of extension? best/bestvideo seems to just pick the highest quality mp4 unless there's a webm with a higher resolution. For example, if the 1080p webm is 150MiB and the 1080p mp4 is 145MiB, youtube-dl picks the mp4 unless there's a 1440p webm available and no 1440p mp4.

I'm using the latest version.

edit:
I've read on reddit that the sole deciding factor for "best" is bitrate. Shouldn't higher bitrate mean bigger file size though? So what's happening here?

[info] Available formats for HEtQWgDldA8:
format code  extension  resolution note
247          webm       1280x720   720p 1494k , vp9, 24fps, video only, 101.34MiB
136          mp4        1280x720   720p 2404k , avc1.4d401f, 24fps, video only, 95.38MiB
@pukkandan
Copy link
Contributor

pukkandan commented Aug 30, 2020

By default, youtube-dl sorts the format by preference, language_preference, quality, tbr, filesize, vbr, height, width, proto_preference, ext_preference, abr, audio_ext_preference, fps, filesize_approx, source_preference format_id in that order.

The problem is that YouTube often reports the wrong tbr (total bit rate) for videos, breaking the best/worst filters. Even if the sort order was to be changed to filesize, tbr, it still wouldn't fix the issue since for many formats (especially DASH), youtube doesnt report the filesize either. The best we can can do in this situation is to use filesize,filesize_approx,tbr. But it doesnt make sense to make this the default since most users dont want the largest video when they ask for bestvideo (not that the current code order gives the best order either).

As a temporary fix until a better sorting method can be created, I had proposed a pull request #25959 to allow the user to specify how to sort the formats. If you are willing to use that branch, --format-sort "filesize,filesize_approx" will give you the largest video irrespective of resolution/bitrate (assuming filesize_approx reported is relatively correct).

Documentation for #25959 :

--format-sort = Sort the formats by the fields given (e.g. height,width,+filesize). Available fields: language_preference, quality, height, width, fps, filesize, filesize_approx, tbr, vbr, abr, format_id, preference, proto_preference, ext_preference, audio_ext_preference, source_preference. Prefix the field (except format_id) by a + to sort it in reverse. preference, language_preference, quality will always have the highest priority unless --format-sort-force is given.
--format-sort-force = User specified sort order takes priority even over preference, language_preference and quality.

@gitfirl
Copy link
Author

gitfirl commented Sep 1, 2020

thanks @pukkandan! it works like a charm!

@afterdelight
Copy link
Contributor

afterdelight commented Feb 18, 2022

just use --format-sort vbr,abr (video+audio bitrate)
it's more simple and accurate

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

Successfully merging a pull request may close this issue.

3 participants