FlorianLeChat / YouTube-Downloader

📺 A simple web page to download videos through YouTube-DL.

Home Page:https://www.florian-dev.fr/youtube/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quality and maximum file size settings don't work properly

legovo opened this issue · comments

commented

I used this video: https://www.youtube.com/watch?v=5v9KeJJ3ofA
When using the Vorbis or MP3 codec, the quality or max file setting doesn't work at all - I get the same file at each setting. When using AAC, only max file size doesn't work (quality setting works). Selecting AAC instead of M4A (or vice versa) gives the same result.

I did some testing and that's what I got:
Audio only, VF:Best, AF:Vorbis, AQ:9, 100M - got 15.3M ogg audio file (500 kbit/s vbr)
Audio only, VF:Best, AF:Vorbis, AQ:0, 100M - got the same 15.3M ogg audio file

Audio only, VF:Best, AF:Vorbis, AQ:9, 8M - got the same 15.3M ogg audio file
Audio only, VF:Best, AF:Vorbis, AQ:0, 8M - got the same 15.3M ogg audio file

Audio only, VF:Best, AF:AAC, AQ:9, 100M - got 1.8M m4a audio file
Audio only, VF:Best, AF:AAC, AQ:0, 100M - got 15.4M m4a audio file (454 kbit/s constant)

Audio only, VF:Best, AF:AAC, AQ:9, 8M - got the same 1.8M m4a audio file
Audio only, VF:Best, AF:AAC, AQ:0, 8M - got the same 15.4M m4a audio file

Audio only, VF:Best, AF:MP3, AQ:9, 100M - got 9.5M mp3 audio file (280 kbit/s vbr)
Audio only, VF:Best, AF:MP3, AQ:0, 100M - got the same 9.5M mp3 audio file

Audio only, VF:Best, AF:MP3, AQ:9, 8M - got 9.5M mp3 audio file
Audio only, VF:Best, AF:MP3, AQ:0, 8M - got the same 9.5M mp3 audio file

Video+audio, VF:3GP, AF:M4A, AQ:9, 100M - got 1.8M 3gp file with mp42 video and m4a audio (24 kbit/s vbr)
Video+audio, VF:3GP, AF:M4A, AQ:0, 100M - got the same 1.8M 3gp file

Video+audio, VF:3GP, AF:Opus, AQ:0, 100M - got the same 1.8M 3gp file

Video+audio, VF:MKV, AF:M4A, AQ:0, 100M - got error saying: '[youtube] 5v9KeJJ3ofA: Requested format is not available. Use --list-formats for a list of available formats'

  • Same with FLV, WebM, OGG, AVI video. Also same with WebM/MKV+FLAC/Opus/Whatever. But that's strange, WebM+Opus was supposed to work.

Thanks again for your feedback, I have made some changes in the code and performed some of your tests with the given music. Some of the criteria seem to be fixed, for others it seems impossible to do something with the limitations imposed and the complexity of using YouTube-DL. First, audio files can be limited in size but this introduces additional complexity to the code because only a few specific extensions are supported.

You can also use a file extension (currently 3gp, aac, flv, m4a, mp3, mp4, ogg, wav, webm are supported) to download the best quality format of a particular file extension served as a single file, e.g. -f webm will download the best quality format with the webm extension served as a single file.

For the moment, I'm dropping this idea and only video files will be affected. Trying to implement this restriction on all downloads and if you use some specific unsupported codecs, then YouTube-DL will systematically propose the "best" ones but they are very far from offering the best music quality (you can also do the test on your side). If you absolutely want to have a size limit, you can always deal with the audio file quality, but I agree this is not the best solution.

yt-dlp https://www.youtube.com/watch?v=5v9KeJJ3ofA --extract-audio --audio-format vorbis --audio-quality 0/9 --format "[filesize<100M]"

Another thing to note is that the music quality definition (--audio-quality) has no influence if the file format is set to best, that's why YouTube-DL will always give you the same file because it doesn't take this criteria into account. Moreover, this option and option to set audio file format (--audio-format) work only if video file is not requested ("Audio only" option) as stated in YouTube-DL documentation.

--audio-format FORMAT           Format to convert the audio to when -x is
                                used. (currently supported: best (default),
                                aac, alac, flac, m4a, mp3, opus, vorbis,
                                wav). You can specify multiple rules using
                                similar syntax as --remux-video
--audio-quality QUALITY         Specify ffmpeg audio quality to use when
                                converting the audio with -x. Insert a value
                                between 0 (best) and 10 (worst) for VBR or a
                                specific bitrate like 128K (default 5)

Finally, if you get errors which indicate that a format is not available or not supported, it is probably because the criteria you requested cannot produce a result, this is especially the case with some audio and video formats/codecs which are not available from YouTube, another cause is a too low file size limit definition which gives no result for YouTube-DL.

In the next few days, I will probably set up the option to re-encode video and audio files to other formats, but this may be an issue due to processing time. I'm listening to you if you have any other feedback!

I added (since my last message) an option to re-encode videos if a format is not available by default on YouTube: 143f8c1 (this option is not available on my demo website because it can cause a significant processing time and since my server is behind Cloudflare, users are likely to experience the famous 524 error). Regarding what has been said about your issue, I have re-tested with this music https://www.youtube.com/watch?v=bXs4Qak780g and it looks like I am getting results similar to what I would get with YouTube-DL's CLI. If you experience an issue again, please let me know.