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

--prefer-free-formats does not prefer webm to mp4 #6018

Open
kparal opened this issue Jun 18, 2015 · 58 comments
Open

--prefer-free-formats does not prefer webm to mp4 #6018

kparal opened this issue Jun 18, 2015 · 58 comments

Comments

@kparal
Copy link

kparal commented Jun 18, 2015

$ youtube-dl 'https://www.youtube.com/watch?v=r9rGX91rq5I' -v -F
[debug] System config: [u'--prefer-free-formats']
[debug] User config: []
[debug] Command-line args: [u'https://www.youtube.com/watch?v=r9rGX91rq5I', u'-v', u'-F']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.06.04.1
[debug] Python version 2.7.10 - Linux-4.0.5-300.1.kparal.fc22.x86_64-x86_64-with-fedora-22-Twenty_Two
[debug] exe versions: ffmpeg 2.6.3, ffprobe 2.6.3
[debug] Proxy map: {}
[youtube] r9rGX91rq5I: Downloading webpage
[youtube] r9rGX91rq5I: Extracting video information
[youtube] r9rGX91rq5I: Downloading DASH manifest
[info] Available formats for r9rGX91rq5I:
format code  extension  resolution note
171          webm       audio only DASH audio  108k , audio@128k (44100Hz), 3.84MiB
140          m4a        audio only DASH audio  127k , m4a_dash container, aac  @128k (44100Hz), 4.76MiB
278          webm       256x144    DASH video   62k , webm container, VP9, 15fps, video only, 1.23MiB
242          webm       426x240    DASH video  112k , 30fps, video only, 1.88MiB
160          mp4        256x144    DASH video  122k , 15fps, video only, 3.37MiB
243          webm       640x360    DASH video  205k , 30fps, video only, 3.59MiB
244          webm       854x480    DASH video  281k , 30fps, video only, 6.15MiB
134          mp4        640x360    DASH video  297k , 30fps, video only, 3.44MiB
133          mp4        426x240    DASH video  307k , 30fps, video only, 7.54MiB
135          mp4        854x480    DASH video  626k , 30fps, video only, 7.05MiB
247          webm       1280x720   DASH video  645k , 30fps, video only, 14.85MiB
248          webm       1920x1080  DASH video 1204k , 30fps, video only, 27.42MiB
136          mp4        1280x720   DASH video 1286k , 30fps, video only, 14.79MiB
137          mp4        1920x1080  DASH video 2521k , 30fps, video only, 29.69MiB
271          webm       2560x1440  DASH video 3741k , 30fps, video only, 66.79MiB
264          mp4        2560x1440  DASH video 5990k , 30fps, video only, 96.12MiB
313          webm       3840x2160  DASH video 9743k , VP9, 30fps, video only, 157.88MiB
266          mp4        3840x2160  DASH video 10775k , h264, 30fps, video only, 152.25MiB
17           3gp        176x144    
36           3gp        320x240    
5            flv        400x240    
18           mp4        640x360    
43           webm       640x360    
22           mp4        1280x720   (best)

$ youtube-dl 'https://www.youtube.com/watch?v=r9rGX91rq5I' -v --get-format
[debug] System config: [u'--prefer-free-formats']
[debug] User config: []
[debug] Command-line args: [u'https://www.youtube.com/watch?v=r9rGX91rq5I', u'-v', u'--get-format']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.06.04.1
[debug] Python version 2.7.10 - Linux-4.0.5-300.1.kparal.fc22.x86_64-x86_64-with-fedora-22-Twenty_Two
[debug] exe versions: ffmpeg 2.6.3, ffprobe 2.6.3
[debug] Proxy map: {}
266 - 3840x2160 (DASH video)+140 - audio only (DASH audio)

Please note that [debug] System config: [u'--prefer-free-formats'] shows that I have preference to free formats enabled, but youtube-dl wants to download mp4 instead (266+140).

@dstftw
Copy link
Collaborator

dstftw commented Jun 18, 2015

This is expected behavior. --prefer-free-formats is only respected when non-free and free formats are of the same quality. 266 (mp4) has higher bitrate than 313 (webm) therefore is selected. You may want to use -f bestvideo[ext=webm]+bestaudio[ext=webm]/best[ext=webm].

@dstftw dstftw closed this as completed Jun 18, 2015
@rg3
Copy link
Collaborator

rg3 commented Jun 18, 2015

I think the option documentation should mention that. Right now it reads:

Prefer free video formats unless a specific one is requested

@kparal
Copy link
Author

kparal commented Jun 18, 2015

The bitrate will never be exactly the same, it will always differ slightly. But higher bit rate doesn't imply higher quality, it depends on the codec. So that assumption is somewhat off.

But as @rg3 says, that option is not about quality, at least as it is currently documented. It says "pick the free format, if it is available". It does not speak about quality at all. So maybe the current implementation is expected by the developers, but certainly not by the users.

And, if only quality is concerned, what would be the point of such an option? If mp4 has slightly better bitrate, it is picked. If webm has slightly better bitrate, it is picked. Such option would have no effect at all, because it is already the default behavior!

So really, this option should mean "I always want free formats, if they are available, otherwise fall back to proprietary formats". That's how I want to configure youtube-dl. Please make it possible. Thank you.

@kparal
Copy link
Author

kparal commented Jun 18, 2015

You may want to use -f bestvideo[ext=webm]+bestaudio[ext=webm]/best[ext=webm].

I can use this, but I guess that will fail for videos which don't have a webm version. So I would have to do this:
-f bestvideo[ext=webm]+bestaudio[ext=webm]/best[ext=webm]/bestvideo+bestaudio/best

However, when I download videos for my tablet (not PC), I want to avoid 4K videos. So I need height filters. And then the filter gets really complicated.

I would much rather have --prefer-free-formats work as documented, than very complicated command line arguments.

@yan12125
Copy link
Collaborator

Opening as I think --prefer-free-formats should behave as documented.

@yan12125 yan12125 reopened this Jun 21, 2015
@dstftw
Copy link
Collaborator

dstftw commented Jun 21, 2015

@kparal --prefer-free-formats won't anyhow help you avoiding 4K, you'll need to use filters anyway.
@yan12125 I don't think this behavior should be changed since it's an expected behavior from the beginning and changing it will break in general the main youtube-dl's purpose - downloading best available quality. Documentation however should be clarified, yes. What you suggest is an --require-free-formats option that was already rejected previousy.

@kparal
Copy link
Author

kparal commented Jun 21, 2015

What I'm saying is that there's no easy way to prefer free formats (regardless of quality, literally prefer) without writing an explosive set of command line arguments. That's also the case of aforementioned #2196 - it gives a workaround, but it's neither simple nor clean, if you want to cover all the cases. (And I don't think anything was rejected - "you are welcome to contribute a patch that adds one").

@dstftw Can you please clarify what is the purpose of --prefer-free-formats as you see it? I still don't understand it. Does it work only for formats with exactly the same resolution/fps/bitrate? Doesn't that have like 0.00001% chance of occurring? Does it make sense to have an option that almost never applies, because bitrate is never exactly the same? What is the logic when that option is not given - a random format is picked, or always a proprietary one?

In my understanding "require" has different meaning than "prefer". When you require a free format, you pick the best free format, and if it is not available, you fail with an error ("free format required, but none available"). When you prefer a free format, you pick the best free format, and if it is not available, you pick the best non-free format.

@kparal
Copy link
Author

kparal commented Jun 21, 2015

One further argument - some Linux distributions like Fedora add --prefer-free-formats to the default configuration file, see here:
http://pkgs.fedoraproject.org/cgit/youtube-dl.git/tree/youtube-dl.conf

The reason is that h264/aac/other codecs are neither installed by default nor offered in the repositories, because of patent issues. So the wish of the package maintainers of youtube-dl is to allow all Fedora/other distro users to make as many videos playable by default as possible - that means they want to configure youtube-dl to download free formats every time it is possible to do so. So that it is really useful for all users, and not just for those who live outside of USA + other countries where software patents apply and installed proprietary codecs. They don't want to require it, because downloading something is better than downloading nothing, but they want to prefer it as much as possible.

@jaimeMF
Copy link
Collaborator

jaimeMF commented Jun 21, 2015

I agree with @kparal, I think that with --prefer-free-formats if the formats have the same resolution it should choose the webm. I don't think that giving higher priority to the filesize and bitrate is the best solution, I don't really know how useful is comparing them for diferent containers.

@dstftw
Copy link
Collaborator

dstftw commented Jun 21, 2015

@kparal I've already stated the purpose of it - downloading free format when both formats are equal according to metadata describing quality. youtube-dl supports not only YouTube so the probability is much higher especially if some metadata is not available.

What is the logic when that option is not given - a random format is picked, or always a proprietary one?

Huh? Not a random but best quality format according to metadata.
@jaimeMF for YouTube giving less priority to filesize and bitrate is likely to be reasonable, but in general probably not.

@rg3
Copy link
Collaborator

rg3 commented Jun 21, 2015

I believe (so basically I'm inventing stuff as I write, haha) people using this option are probably interested in downloading free formats if available, just like the current option documentation suggests.

So if a given website (YouTube or other) offers videos in either MP4 or Webm, using --prefer-free-formats should pick a Webm one, and should only download MP4 if no free formats are available.

Once that "format filter" has been applied, it should choose the highest quality one, or obey other format restrictions the user may have specified.

But then we can raise other questions. For example, someone may want to have --prefer-free-formats in the config file, but in a specific case (s)he may want to specify a format filter that wouldn't work with that, so they need a second option to override the config file setting in a given program call (as in --no-prefer-free-format).

Just my two cents. You know I don't want to have any voting weight in the development process and I don't even use that option, so it's irrelevant to me. :P

@kparal
Copy link
Author

kparal commented Jun 21, 2015

I've already stated the purpose of it - downloading free format when both formats are equal according to metadata describing quality. youtube-dl supports not only YouTube so the probability is much higher especially if some metadata is not available.

So IIUIC --prefer-free-formats has no effect on YouTube videos, because full metadata is available, and the videos are always at least slightly different (the bitrate is never the same), so it never happens that this option is taken into account. It can happen on other video sites, which don't provide full metadata, but not on YouTube. That's... suboptimal.

And it doesn't help at all to those users who don't have proprietary codecs installed, and want to download free fomats without hand-picking them every time.

@dstftw For you, quality might be the most important factor. But this belief is not universal and other groups of users might have different priorities. Like open formats. I'm one of them, I believe that patented formats need to be purged from this world and I'll gladly sacrifice some quality because of it. It would be great to have an option which would allow such groups of users to use youtube-dl easily. It can be a new option, if needed (even though in my personal opinion it would make most sense to just use the current one, especially since it currently doesn't seem to have any effect on the largest and most widely used video site).

@jaimeMF
Copy link
Collaborator

jaimeMF commented Jun 21, 2015

--prefer-free-formats is expected to pick free formats only if they have the same quality, which is the tricky point, and I think that's the correct behaviour. If someone wants to really prefer the free formats (even if webm is only 1080 and mp4 is 4k) they can use a custom -f or we could add an additional flag.

@dstftw I think we should only take into account the resolution for --prefer-free-formats, in the case that two formats with the same extension exist we would still use the bitrate and other fields to sort them, I don't think it would be a big problem.

@dstftw
Copy link
Collaborator

dstftw commented Jun 21, 2015

@jaimeMF if some hoster serves formats of the same resolution but really bad bitrate for free format it will end up selecting free format for --prefer-free-formats that is obviously wrong since they are not the same quality and it violates

--prefer-free-formats is expected to pick free formats only if they have the same quality

So, with your suggestion the general semantics of --prefer-free-formats changes to: select free formats when resolutions are equal and not formats of the same quality. In this situation (if we change the semantics of the option) I guess it's indeed more reasonable to change it to what @kparal suggested: select best free format if available otherwise fallback to any best.

@jaimeMF
Copy link
Collaborator

jaimeMF commented Jun 21, 2015

@jaimeMF if some hoster serves formats of the same resolution but really bad bitrate for free format it will end up selecting free format for --prefer-free-formats that is obviously wrong since they are not the same quality and it violates

Yes, that's true, but my point is that deciding if two formats have the same quality (for --prefer-free-formats) is complicated and I would choose to use the resolution. For example, from the output posted by @kparal:

248          webm       1920x1080  DASH video 1204k , 30fps, video only, 27.42MiB
136          mp4        1280x720   DASH video 1286k , 30fps, video only, 14.79MiB
137          mp4        1920x1080  DASH video 2521k , 30fps, video only, 29.69MiB

It prefers 720 mp4 over 1080 webm based just on the bitrate, for me it's more sensible to prefer resolution. But I understand it's not so simple (and my knowledge is quite limited, so I may be completely wrong).

So, with your suggestion the general semantics of --prefer-free-formats changes to: select free formats when resolutions are equal and not formats of the same quality. In this situation (if we change the semantics of the option) I guess it's indeed more reasonable to change it to what @kparal suggested: select best free format if available otherwise fallback to any best.

I wouldn't say it changes, it would "fix" it, since that's how it was supposed to work (at least that's my impression when looking into the original implementation, it seem that it picked the mp4 file if it was the one with the highest resolution). Additionally with that behaviour you could use formats filters like best[height<720] and you would get the format with the height closest to the requested and it would try to pick the free version. With the proposed behaviour it would pick the closest free format, which may not be the one with the highest height.

Anyways, since this is probably a bit subjective and I don't use that option, I don't really mind what it does as long as we clearly document what it does and add tests to verify we don't break it.

@yan12125
Copy link
Collaborator

Thanks @jaimeMF my interpretation of --prefer-free-formats is the same. However, I can't speak for others because I don't use it.

Prioritizing resolutions than bitrates is reasonable. Technically free formats often have lower bitrates than non-free formats. Take VP9 for example, it aims to "Reduce video bitrate by 50% with image quality comparable to VP" ( VP9 requirements ). In other words, bitrates is not a synonym of quality. In real cases, it's uncommon for VP9 to have higher bitrates than H264. As a result, relying on bitrates is problematic.

@haasn
Copy link
Contributor

haasn commented Mar 15, 2016

I always thought that --prefer-free-formats would prefer free formats over proprietary formats at all costs. It is in this issue that I learned it does not. (Not the documentation!).

If I'm specifying this option, odds are that I either:

  1. Want to use a free format for ideological reasons
  2. Don't have proprietary codecs supported on my system

So I think it's fair to choose a lower-quality free format over a higher-quality fair proprietary format when this option is specified.

@ghost
Copy link

ghost commented Mar 15, 2016

That should probably be a separate flag, such as "--only-free-formats".

The main issue was that while getting only free formats was relatively easy ("-f bestvideo[ext=webm]+bestaudio[ext=webm]/best[ext=webm]"), it got really complicated if you wanted to get the highest resolution video, and then prefer the free format if it had one which would lead to such horrors as:
-f bestvideo[ext=webm,height=1080]+bestaudio[ext=webm]/bestvideo[ext=webm,height=720]+bestaudio[ext=webm]/bestvideo[ext=webm,height=640]+bestaudio[ext=webm]/bestvideo[ext=webm,height=480]+bestaudio[ext=webm]/bestvideo[ext=webm,height=240]+bestaudio[ext=webm/best[ext=webm]

with entries for every possible video size you could expect. This was further complicated by the fact that youtube periodically introduces higher resolutions (such as 1440), and things like 3D videos, which mean you have to continually retune the script to add new resolutions to a massive list.
(Edit: Or by making a custom script that runs -F and parses the text looking for the highest res free format, which is another undertaking that's much more effort than most people can or should be bothered with.)

@haasn
Copy link
Contributor

haasn commented Mar 15, 2016

This seems like a conflict of interests. If you make this behavior a separate flag, then --prefer-free-formats no longer has a solid reason to exist.

There's no inherent reason to prefer free formats over proprietary formats other than ideological ones.

The way I see it, the gigantic format string you are describing is born from a need to work-around a different youtube-dl limitation: The fact that it doesn't understand that VP9 is higher quality than AVC even at lower bitrates.

But why are we spending so much time focusing on a work-around instead of improving the core problem here?

Note: I use a similar such work-around, namely:

(bestvideo[vcodec=vp9]/bestvideo[height>720]/bestvideo[fps>30])[tbr<13000]+(bestaudio[acodec=opus]/bestaudio)/best

But I consider this a pure work-around simply because I really don't care if my video stream is VP9 or AVC. I'm just special-casing VP9 because of aforementioned youtube-dl bug.

@utack
Copy link

utack commented Mar 1, 2017

This should work:
ytdl-format="((bestvideo[vcodec^=vp9]/bestvideo)+(bestaudio[acodec=opus]/bestaudio))/best"

@aufkrawall
Copy link

Thanks a lot!
Is there a chance to also make it use Vorbis instead of AAC when it is available?

@utack
Copy link

utack commented Mar 1, 2017

In the case I posted above it will only select opus when a video is found I should mention, for pure audio streaming sites it falls back to "best"
But you can add more and more terms any time
(bestaudio[acodec=opus]/bestaudio[acodec=whateverelse]/bestaudio[acodec=yetanothercodec]/bestaudio)

@aufkrawall
Copy link

Thanks again, got it working. :)

@davidhedlund
Copy link

davidhedlund commented Mar 7, 2017

@utack How is it going to look for WebM container with Vorbis video and Opus audio?

@0xallie
Copy link
Contributor

0xallie commented Jul 3, 2017

To those who suggest that it's simple to replicate the preference / requirement for free formats with -f, it's not entirely true. As you can see from the discussion above, there are multiple free formats, and the format string can get messy.

To make everyone happy, perhaps we could keep --prefer-free-formats as-is (prefer highest resolution/quality and then free format if available), and add --prefer-free-formats=always to prefer free formats even at the expense of quality. And perhaps a --require-free-formats could be added, which will obviously always either download the highest quality free format available, or if there is none, error.

And while it's not entirely on-topic here, I have also noticed that youtube-dl incorrectly prefers H.264 over VP9 due to the slightly higher bitrate. I don't know what's the best solution to that problem though, as you can't necessarily just say VP9 is always better than AAC, because there's a possibility a site will make a worse-quality VP9 encode than H.264 for the same resolution.

@haasn
Copy link
Contributor

haasn commented Jul 3, 2017

And while it's not entirely on-topic here, I have also noticed that youtube-dl incorrectly prefers H.264 over VP9 due to the slightly higher bitrate. I don't know what's the best solution to that problem though, as you can't necessarily just say VP9 is always better than AAC, because there's a possibility a site will make a worse-quality VP9 encode than H.264 for the same resolution.

The approach that always pops in my head is introducing “bitrate coefficients”, perhaps based on some commonly available codec benchmark. (Basically, the idea is that if VP9 encodes ~20% smaller files than H.264 at the same visual quality, as assessed by an objective quality metric such as MS-SSIM, then you can multiply 1.2 into the VP9 bitrate)

@utack
Copy link

utack commented Jul 3, 2017

@haasn Has anyone found a VP9 with same resolution and FPS that looked worse than the H264 counterpart yet?
Does not seem to happen generally with the settings they use

@haasn
Copy link
Contributor

haasn commented Jul 3, 2017

@utack I remember seeing some pathological VP9 encodes of video game streams a year or two ago, specifically Dwarf Fortress. May have changed in the meantime, and I may be misremembering, but afaik you'll still find weird clips like that where x264 is still hard to beat, in some of the areas it's specifically tuned for.

@Hrxn
Copy link

Hrxn commented Jul 4, 2017

Has anyone found a VP9 with same resolution and FPS that looked worse than the H264 counterpart yet?
Does not seem to happen generally with the settings they use.

Well, at least not on YouTube.
But haasn is right, some bitrate reference value for comparison would be a good idea.
Another thing I noticed, YouTube specific: Some newer videos, on official channels, music videos etc. had VP9 and H.264 with more or less the same bitrate, thus eliminating the potential file size benefit of VP9 for the sake of better visual quality. I don't know any YouTube Insider, but maybe that is their current strategy, adapting for higher availability of broadband Internet access across the user's population.

@haasn
Copy link
Contributor

haasn commented Jul 4, 2017

But haasn is right, some bitrate reference value for comparison would be a good idea.

For lack of anything better, we could use netflix's results (which are normalized to the VMAF metric).

netflix codec efficiency

This seems to suggest that e.g. at 1080p, a coefficient of “1.4 * bitrate” for VP9 and “1.5 * bitrate” for HEVC would be good candidates. (This scale would presumably normalized such that x264 represents the reference)

@fireattack
Copy link

fireattack commented Jul 4, 2017

Even if we decided the "coefficient" for each format, how we're going to deal with the fact that YouTube sometimes straightly reports wrong bit-rate?

@haasn
Copy link
Contributor

haasn commented Jul 4, 2017

Probably by ignoring the “bitrate” and using the filesize, or something. Actually, looking at e.g. youtube-dl -F https://www.youtube.com/watch\?v\=KQs0Gj7bXYY:

...
247          webm       960x720    720p 2092k , vp9, 30fps, video only, 319.30MiB
136          mp4        960x720    720p 2249k , avc1.4d401f, 30fps, video only, 437.94MiB
298          mp4        960x720    DASH video 3348k , avc1.4d4020, 60fps, video only, 683.20MiB
302          webm       960x720    720p60 3891k , vp9, 60fps, video only, 591.97MiB
...

Comparing formats 298 and 302 specifically, if we assume 3348k is the true bitrate for the 683.20MiB H.264 stream, then
the VP9 stream's reported bitrate of 3891k is roughly “1.34x” higher than what it should be going by the filesizes. So
maybe youtube already internally gives VP9 a format-specific “bitrate” boost?

@fireattack
Copy link

Well it doesn't always return file-size.

@davidhedlund
Copy link

@nyuszika7h

And perhaps a --require-free-formats could be added

Add --require-free-formats was declined but with your vote on the issue they might change their mind.

@Hrxn
Copy link

Hrxn commented Jul 4, 2017

Well it doesn't always return file-size.

Example?

@fireattack
Copy link

fireattack commented Jul 4, 2017

AFAIK, all the DASH ones don't return file-size. Edit: not all DASH videos, but a lot of them are.

youtube-dl -F https://www.youtube.com/watch?v=eYztYCbV_8U

Which is also an example I mentioned before that reports wrong bitrate (original report: #11451), but it seems YouTube already corrected the bitrate issue for this particular one (format 136 now correctly shows lower bitrate than 137).

youtube-dl -F https://www.youtube.com/watch?v=iMhwshjSauo

This still shows no file-size information and wrong bitrate info

It reports

135          mp4        720x480    DASH video  198k , avc1.4d401e, 30fps, video only
133          mp4        360x240    DASH video  242k , avc1.4d400c, 30fps, video only

actual bit rates: 135: 112kbps 133: 32kbps


I know those are not "free formats", but this topic has already became the place to discuss "should we choose best video/audio merely based on bitrate (current behavior)", and the fact YouTube sometimes returns totally erroneous bit rate info should be taken into consideration before we start theorizing things like "weighted bitrate". I'm still baffled why we don't use resolution first as quality indicator, which has virtually no drawbacks.

@cloph
Copy link

cloph commented Jul 5, 2017

To make everyone happy, perhaps we could keep --prefer-free-formats as-is (prefer highest resolution/quality and then free format if available)

@nyuszika7h : the problem is that this is not how it behaves as-is. If that was the case, everyone would be happy indeed.
--prefer-free-formats as it is now acts like a --force-free-formats and this causes all the problem. (aka the need for overly long selector/filter lines instead of a simple [height <= 1080p] and --prefer-free-formats) see my previous comments for more details.

@glenn-slayden
Copy link
Contributor

glenn-slayden commented Sep 7, 2017

I agree with the comments made by @fireattack above here and here that resolution should be used instead of bitrate for the -f bestvideo determination.

Rather than continue to hijack the --prefer-free- debate, I created #14143 (albeit before discovering the comments I cited here in this unrelated issue).

One unqualified demerit of using bitrate--or for that matter, anything-rate--during the bestvideo determination is that the time denominator is irrelevant when comparing alike-length alternatives. Since the length is exactly the same for all the entries in a given youtube-dl -F format listing, you can multiply by every rate value in the table by the same duration (video length) to "simplify," or mathematically cancel the division which created that "rate."

Given a "most pristine" master copy which must exist for every video, entropy can be dissipated in several dimensions, but duration time is not one of them. Either the compression algorithms are more/less efficient, or the frame dimensions or frame rate are different. And it seems to me that given the special constraint discussed above, the latter two will swamp the former in all cases, making some sensible combination of dimension and fps a much more stable indicator of "best."

I think that, possibly, people have gotten in the mindset of elevating bitrate because it is quite likely a better indicator of quality when comparing dissimilar source material, but this habit may be obscuring better judgment when it comes to the specialized task of comparing all-alike material.

Irrefutably, really, bitrate is just a needlessly complex proxy for the total entropy each available format ultimately makes available. Add in the fact that the YouTube reported bitrate values are often wildly wrong (in fact far more so than this thread has reported; see #14143) and it's clear that by the nature of this type of selection task, bitrate is not the way to go.

So as I've noted, the -f bestvideo determination task, as with tasks in general, can and should capitalize on the special properties that are particular to it. In this case, this means recognizing the exclusion of time-denominated metrics as mathematically vacuous, and therefore unnecessarily complicating:, i.e., at best a harmless obfuscation, and at worst, exposing a tangibly increased error surface.

@aufkrawall
Copy link

I use this setting in mpv to always get VP9 + Opus/Vorbis, as suggested by utack (thanks again!):
ytdl-format="((bestvideo[vcodec^=vp9]/bestvideo)+(bestaudio[acodec=opus]/bestaudio[acodec=vorbis]/bestaudio[acodec=aac]/bestaudio))/best"
Is it possible to additionally also always prefer HDR video when it is available?

@haasn
Copy link
Contributor

haasn commented Sep 30, 2017

@aufkrawall Yeah, it gets identifies as vp9.2

I use this:

ytdl-format=(bestvideo[vcodec=vp9.2]/bestvideo[vcodec=vp9][fps>30]/bestvideo[vcodec=vp9][height>=1080]/bestvideo[fps>30]/bestvideo[height>720])+(bestaudio[acodec=opus]/bestaudio)/best

@aufkrawall
Copy link

Great, just added vp9.2 and it works like a charm.
As always: Thanks a lot!

@ZYinMD
Copy link

ZYinMD commented Sep 20, 2020

When people visit youtube from chrome, and click on a video, and hand pick the highest resolution, (for instance 1080 60fps), is there a good chance youtube would arbitrarily decide to serve webm?

If yes, maybe we could have an flag prefer-website-decision, which works like this: "choose the highest resolution, then accept the file format chosen by the website when serving to a desktop browser with good hardware, fast internet, and all codecs". This way, we will get webm if the server believes it's a good choice, no matter the bitrate.

Let's face it, newer codecs are expected to have lower bitrates. That's the goal when they were developed.

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

No branches or pull requests

15 participants