question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"-f ba*" doesn't select best audio

See original GitHub issue

Checklist

  • I’m reporting a bug unrelated to a specific site
  • I’ve verified that I’m running yt-dlp version 2022.03.08.1. (update instructions)
  • 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 issues including closed ones. DO NOT post duplicates
  • I’ve read the guidelines for opening an issue

Description

-f ba* doesn’t select best audio that may contain video but best video that contains audio because the sorting field hasvid has the highest priority unless you also use --format-sort-force and something like -S acodec or -S abr.

Examples:

  1. yt-dlp.exe https://www.youtube.com/watch?v=iik25wqIuFo downloads format ID 248+251 (best video and best audio, correct)
  2. yt-dlp.exe https://www.youtube.com/watch?v=iik25wqIuFo -f ba* downloads format ID 22 (best video+audio, wrong)
  3. yt-dlp.exe https://www.youtube.com/watch?v=iik25wqIuFo -f ba* -S acodec --format-sort-force downloads format ID 251 (best audio, correct)

Using only -f ba works in this case, but what if there is a video format with better audio than an audio-only format?

Suggestion: If I want the best audio format, yt-dlp should change the default sorting order to favour better audio formats, independently of video.

I’m not sure if this only relates to Youtube, but I don’t know which other site I could test this on.

Verbose log

[debug] Command-line config: ['https://www.youtube.com/watch?v=iik25wqIuFo', '-f', 'ba*', '-vU']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, err utf-8, pref cp1252
[debug] yt-dlp version 2022.03.08.1 [c0c2c57] (win_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.22000-SP0
[debug] exe versions: ffmpeg N-105919-g546afd0d49-20220313 (setts), ffprobe N-105919-g546afd0d49-20220313
[debug] Optional libraries: brotli, Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
Latest version: 2022.03.08.1, Current version: 2022.03.08.1
yt-dlp is up to date (2022.03.08.1)
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=iik25wqIuFo
[youtube] iik25wqIuFo: Downloading webpage
[youtube] iik25wqIuFo: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[info] iik25wqIuFo: Downloading 1 format(s): 22
[debug] Invoking downloader on "https://rr2---sn-5jvoxu-8pxe.googlevideo.com/videoplayback?expire=1647465486&ei=rv8xYqn2FIPp1gKn_bKIBw&ip=XXX&id=o-ANn_lYxWdx7i5pfnmNMZqe5J7h8SKKB6nvesCom0H-hF&itag=22&source=youtube&requiressl=yes&mh=lR&mm=31%2C29&mn=sn-5jvoxu-8pxe%2Csn-2gb7sn7k&ms=au%2Crdu&mv=m&mvi=2&pl=19&initcwndbps=1132500&vprv=1&mime=video%2Fmp4&ratebypass=yes&dur=7.244&lmt=1641462248093086&mt=1647443362&fvip=2&fexp=24001373%2C24007246&c=ANDROID&txp=5311224&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRAIgaU9VctCnxz21Qm69vsY5sd4qh8oiyjcTftOwZfVFwlICIFetHaFH5xrnMMBNlddLpdF2BLdTEFEXIsAL-R7WjCVW&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhAKyTai83UGb7ZTTxZcghC_fpWxLdCWDJDsv1mZBfnB9xAiBQmOxnu9TMhfVl5CuCeSRW0rtWZzno8PDYLDTq4SdjcQ%3D%3D"
[download] Destination: Rick roll, but with different link [iik25wqIuFo].mp4
[download] 100% of 1.09MiB in 00:00

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gorbiWTFcommented, Mar 17, 2022

Well, that’s too bad.

Example 1: I just want to download a video. yt-dlp chooses the best audio-only format, the best video-only format and combines them. Example 2: I want to download the best audio (which may also contain video). But yt-dlp chooses the best video-with-audio-format. Example 3: I want to download the best audio-only format. yt-dlp chooses the best audio-only format.

I don’t get it why there is a difference between example 1 and 2. To me it seems like -f b and -f ba* yield exactly the same result.

I guess I just have to use the “longer” way. Thanks for the answer!

0reactions
gorbiWTFcommented, Mar 22, 2022

Thanks, but -x doesn’t change the downloaded format, unfortunately.

Do -x --audio-format "mp3" for that where you can replace “mp3”.

It’s not about the file I get after the download, but what format ID gets chosen by yt-dlp.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does "-f bestvideo+bestaudio" on yt-dlp actually give the best ...
Then, someone said that -f bestvideo+bestaudio should never be used because it doesn't necessarily give the best quality, only the highest ...
Read more >
12 Tips for the Best Sound Quality in Your Car - Crutchfield
These car audio tips can help improve sound quality in your vehicle, whether you're listening on a factory system or a multi-channel amplified...
Read more >
Ultimate surround sound guide: DTS, Dolby Atmos, and more ...
Surround sound is a great add-on to any TV setup, but the jargon is enough to make you dizzy. From DTS to Dolby...
Read more >
Realtek HD Audio low and bad quality sound after Windows ...
Find and select the "Sound Effects" tab under the main volume slider. Check the Loudness Equalization box (mine was not checked by default)....
Read more >
Voicemeeter or Audio problem after WIN10/11 update (JAN ...
In fact all the audio stack can be impacted by a WIN10 update and make ... audio, frozen app), or with device (the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found