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
Is there an option that yields the best available audio quality among all formats? #9302
Comments
Short: there is no such option. |
I don't, actually. |
@Bl-rp interpreted the meaning of those options perfectly and his request is perfectly valid. He's requesting an option like "bestavailableaudio" which decides, among all audio-only formats AND video+audio formats, where the best possible audio is. If the audio is an audio-only format, then simply download it, otherwise, if the best audio is contained in a video+audio format, then download the file and extract the audio, as with the -x option. I also would like to see the feature implemented. While it is true it is not common, it sometimes happens that the audio in the video+audio format is better than any audio-only format. EDIT: In fact, the default download Youtube-dl does on that video (no format options supplied) is actually one of the worst quality videos. Something is not right in the quality decision. |
Example? |
I was refering to the video on the OP by @Bl-rp. This one: https://www.youtube.com/watch?v=J9bjJEjK2dQ |
In the current implementation, bitrates have a higher priority than resolutions. There are already lots of debates - some developers (including me) believe resolution should be the first key to determine the quality, while others think bitrates should be the leading criteria. See #6018, #5491 for debates and #8125 for a possible solution. |
Ok I see. And what about sound? What is the criteria for choosing the best audio? Bitrate? Is format taken into account? |
In general bitrate is the first criterion, and filesize is the second. Audio formats are not used unless |
I came here to request this "feature" --extract-audio on youtube.com seems a bit random, but this is understandable. M4a usually seems to be the highest bitrate audio on youtube, would a --prefer-m4a switch help at all? |
It may work in some cases but not aforementioned J9bjJEjK2dQ, where almost all audio streams are m4a. |
Quite often .webm is "best" both among audio formats and video+audio. |
Statistics is not reliable. A new feature should always work correctly. |
I think that's the case for I'd love to have an option to grab the best possible audio from either the audio-only or audio+video available options, and I don't think it would be hard to implement such logic. The problem is that (as far as I can tell) youtube-dl does not know (cannot know?) how much audio is in the audio+video file. Is that information available? If not, for the example above, the format 22 has a total bitrate of 192k so it could theoretically have better audio than the 160k audio only one, if the 1280x720 video stream were supercompressed to just 10k (is that even possible? maybe not, but hopefully you get my point: it's a problem to guess the audio bitrate in an audio+video stream whose only total bitrate is known). So the key question is: can the audio bitrate of a mixed audio+video stream be known? I don't see it in the output of |
They are unknown before downloading if not in the output of |
So what about downloading the best video, then extracting the audio, then downloading the best audio and comparing it with the extracted audio from best video? Could there be an option for this? |
@jihg: That's already possible to download multiple formats with extracting audio. For example:
The last step - comparing - is left to you. It's infeasible to create automatic comparing algorithms as there are quite a few audio codecs. |
@yan12125 I mean, the same way youtube-dl compares the streams when choosing best, could be used to compare those results, couldn't it? |
I don't think there will be a simple and satisfying algorithm. For example, if you have opus@153k and mp4a.40.2@125k, is the former unconditionally better? |
@yan12125 but then how does youtube-dl determine |
The current implementation compares all audio-only formats by bitrates. That said, if you don't care whether the downloaded file is the best, the second best or even the third best, comparing by bitrates is OK. If you are serious about quality, you should download all possible formats and compare them by yourselves. |
@yan12125 : given that a I agree on what you say that for a perfect result you should be comparing the quality manually, or at least take into account many other factors, but if the comparison criteria above are considered good enough when comparing among If you don't find such an option reliable, then |
I don't know if it can be of any interest here but with regard to this topic I just found another non-dumb youtube downloader app that similarly to youtube-dl actually analyzes all audio sources (both DASH and muxed) but goes on by picking the best audio based on the highest bitrate among all of them. <removed> |
First, comparing bitrates of
There are indeed quite a few discussions for best* options and callings for changes. For example, #8125, #6018. |
@yan12125 why not? Aren't we simply comparing the bitrates of two plain audio files at that point (provided -x is used on both bestaudio and best)? Yes the two files might be encoded with different codecs, but so could be the bestaudio candidates... so, why not? |
bestaudio works for me, it is good enough (haven't actually spent enough time downloading all the best formats and comparing tbh) am curious though if there is a way to download the best audio then convert to an m4a, yeah yeah, i know compressing a compressed files should result in less quality, only need to convert if it is not already a m4a though. I have a feeling the correct answer to this question is: write a script around youtube-dl since all the information is available and adding this kind of functionality is outside of the scope of youtube-dl. example video where perhaps the best audio is in 22 (mp4 1280x720)
Reason I am here is because I want to grab this playlist https://www.youtube.com/watch?v=WPni755-Krg&list=RDQM13Ux3JPdInk and only have m4a files, even though perhaps the webm files could be best quality... snap, having just typed all that up I have remembered that there is an android app that can do a pretty good job - removed, wasn't an ad. edit: not an ad. it would be ideal if I could also get the same filetype (all m4a) out of "youtube-dl -f bestavailableaudio playlist.url" with zero effort rather than a mix of file formats. |
This does not add anything valuable to the discussion. It's already a complicated topic deciding what the best audio should be and you're only adding noise and honestly your comment looks more like an advertisement to a paid product than anything else. The app you talk about is misleadingly named "donationware" but what really is is a freemium that will only let you download music after you "donate" $2. |
@davidedelvento @SoreGums Opus at 160kbps outperforms AAC at 192kbps. |
I use the following command/options and happy with the result. It downloads the Opus 160kbps and convert it to mp3(VBR)
|
@mmshasan that will imply transcoding which means adding additional artifacts = lower quality. |
@nickcassol mentioned that format may be more important than bitrate Possibly this will be helpful in determining which video format is best: VP9 outperforms avc1 according to https://motovlog.com/threads/making-1080p60-look-like-4k-by-getting-youtubes-bigger-bit-rate.17619/post-156037 if you want to download best opus+vp9 video:
if you want to download best opus audio:
in future when av1 will become more available it will be even better choice than vp9 https://aomedia.org/av1-features/ if you want to download best opus+av1 video:
|
Hi @qqgg231, |
@jjgh
|
-f bestaudio should work with youtube-dl.
Also on new youtube videos, from my personal appraisal, youtube.com is using
128KB/s AAC to encode all other audio formats, as that is the archive
format after upload. so that would be number one-forty. Other formats
might still sound better, but that format should have less audio artifacts
and be closer to the source coded file.
|
This comment explains that
One user did an experiment about it and result was Youtube keeps original file, not reencoded to AAC: https://www.quora.com/Does-YouTube-keep-the-original-uploaded-video-files Also please look at this comment: #9302 (comment) |
Testing with one of the YT launch videos (https://www.youtube.com/watch?v=2nXYbGmF3_Q), the AV1 streams are detected and can download properly (Using the numeric code), but something like They're also using the MP4 container since it's technically not valid for WebM, and youtube-dl emits a warning about it. |
Cause there is no such exact |
Yep, discovered that right after posting 😑 |
I'm affected, too, but rather in terms of video than regarding audio. In case someone implements this sometime, here is an example of this issue affecting the video resolution: https://www.bbc.co.uk/programmes/p02k4zqd While |
I'm struggling really hard w/ this issue of quality; please email(mine's is public) its name to me. thank you |
Same here please, why the fuck censorship? |
good Q; youtube-dl is non-profit(?) so it doesn't make sense to censor competition |
@zoklev I can't see your email in your profile... |
Mine is visible :) |
Did you get my mail? |
I want to be able to download the best quality audio available.
-f bestaudio
doesn't always yield the best available audio, as sometimes the best audio only version has worse audio than the best video+audio version. See the example video:-f bestaudio
yields 125 kbps m4a, and-x -f best
yields 192 kbps m4a. I think I've seen an example of-f best
yielding worse quality than-f bestaudio
too, but I'm not sure.Does
-f best
in fact always yield the best audio?If not, is there an option that always yields the best audio?
If not, I would like to request such a feature. In fact, the way it's described, it sounds like the default option is intended to yield the best quality audio and video, and that's certainly what I expected. Also, is it guaranteed that either
-f best
or-f bestaudio
yields the best audio? It's conceivable that there could be a video where the best audio-only version has medium quality, the best overall version has medium quality audio and high quality video, and there exists a version with high quality audio and low quality video, and then the answer would be 'no'.The text was updated successfully, but these errors were encountered: