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
[youtube] Video codec selected by yt-dlp doesn't provide the highest quality #458
Comments
AV1 isn't really widely supported yet but users can just use something like |
-S res,codec:av1,codec:h264,codec:vp9 does what I want. |
This is not a general rule. The relative quality of different encodings depends on a lot of factors including the actual content of the video itself. There is no objective way of testing the actual "quality" of the video formats without downloading them first. Generally,
No. This is equivalent to just using Currently, the only way to do |
This is really confusing for me. When I saw this in
Until I saw this issue, I thought it would prefer av1 codec by default since av1 is the best codec before h266(VVC) is coming out.
This is not true. There are some free and open-source decoders like dav1d, which uses CPU to decode instead of some specific hardware. With proper player apps, most of my devices can play av1 videos (including my 3-years-old iPhone, my 4-years-old Google Pixel, my MacBook Pro, and my Windows PC). |
This is not true. YouTube re-encodes every video no matter that the original codec of the video is. After re-encodes, every format YouTube offers would be lossy. From my experience, |
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 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 |
I respect the decision you made, I just want to point out the container formats that |
like |
#458 (comment) did not work for me currently im using multiple calls to yt-dlp H=720
f="bestvideo[height<=$H][ext=mp4]+bestaudio[ext=m4a]/0/iphone-$Hp/best[height<=$H]"
# h264 > av1 > vp9
yt-dlp -f "$f" -S vcodec:h264 "$@" ||
yt-dlp -f "$f" -S vcodec:av1 "$@" ||
yt-dlp -f "$f" "$@" |
@pukkandan Doesn't work when also using something like: |
Checklist
Verbose log
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:
All of the screenshots were taken using mpv with screenshot-format=png
The text was updated successfully, but these errors were encountered: