[youtube] Video codec selected by yt-dlp doesn't provide the highest quality
See original GitHub issueChecklist
- I’m reporting a broken site support issue
- I’ve verified that I’m running yt-dlp version 2021.06.23
- I’ve checked that all provided URLs are alive and playable in a browser
- I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
- I’ve searched the bugtracker for similar bug reports including closed ones
- I’ve read bugs section in FAQ
Verbose log
[debug] Command-line config: ['--skip-download', 'https://www.youtube.com/watch?v=Dnw6-ntk3SY', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] yt-dlp version 2021.06.23
[debug] Python version 3.9.5 (CPython 64bit) - Linux-5.12.7-gnu-hardened1-1-hardened-x86_64-with-glibc2.33
[debug] exe versions: ffmpeg 4.4, ffprobe 4.4, rtmpdump 2.4
[debug] Proxy map: {}
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=Dnw6-ntk3SY
[youtube] Dnw6-ntk3SY: Downloading webpage
[youtube] Dnw6-ntk3SY: Downloading MPD manifest
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] Dnw6-ntk3SY: Downloading 1 format(s): 303+251
Description
By default yt-dlp seems to download videos encoded with the VP9 codec first which from my tests doesn’t seem to offer the best possible quality when downloading from youtube.
When youtube only offers a video in VP9 and H.264 then H.264 has the highest quality:
https://www.youtube.com/watch?v=Dnw6-ntk3SY
https://www.youtube.com/watch?v=fy16LjNLWjk
And in the case when youtube also offers the video in AV1, then it seems that AV1 > VP9 > H.264 in terms of quality:
https://www.youtube.com/watch?v=spcauG9AnGI
https://www.youtube.com/watch?v=RAhqxvgQYn0
My guess is that the quality depends on which codec was used by the original video. I think that most people use H.264 so the version reencoded to VP9 has lower quality and when a video is available in AV1 then it was the original codec used to encode the video so it has the highest quality. VBR reported by youtube doesn’t seem to play a role here, because when comparing the quality of these videos: https://www.youtube.com/watch?v=spcauG9AnGI (Highest VBR - H.264) https://www.youtube.com/watch?v=rXHpFOG-fcY (Highest VBR - VP9) https://www.youtube.com/watch?v=RAhqxvgQYn0 (Highest VBR - AV1) all of them seem to have the highest quality in AV1 even though the codec with the highest VBR seem to be different for every video.
It should be possible to solve this by changing the format sort used by the youtube extractor to first check for AV1 then for H.264 and only then for VP9.
Command I’ve used to download videos for comparison:
yt-dlp VIDEO_URL -f FORMAT
All of the screenshots were taken using mpv with screenshot-format=png
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
The readme was recently edited to clarify this.
I will make AV1 default only after atleast all major OSes start supporting it See this list. Hopefully, most new devices will also have hardware support for it by then
I don’t understand why people complain about this. You have the option to just put something like
-S res,vcodec:av1
in a config file and forget about it.The default option should work for the most non-techie users and a codec that is still not natively supported on popular OSes is not a good default
like
-f "(bv*+ba/b)[vcodec=av01] / (bv*+ba/b)[vcodec=h264] / (bv*+ba/b)[vcodec=vp9] / (bv*+ba/b)"
?