Skip to content
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 links pick descriptive audio instead of original #1268

Closed
ltguillaume opened this issue Aug 25, 2021 · 11 comments
Closed

YouTube links pick descriptive audio instead of original #1268

ltguillaume opened this issue Aug 25, 2021 · 11 comments

Comments

@ltguillaume
Copy link

Example: https://youtu.be/BJ_PrIVI5Ac

MPC-HC picks the "English descriptive" audio track instead of "English original" and I don't understand why. MPC-BE doesn't, and when I use YouTube-dl directly, it doesn't pick "English descriptive" either. I tried with and without "eng" in default audio track preference.

@clsid2
Copy link
Owner

clsid2 commented Aug 25, 2021

When there are two identical tracks in terms of quality (codec/bitrate) then it currently simply picks the first one.

YDL JSON output does not contain any language or track description. Only difference in this case is tags in the URL.

I am not going to spend time to fix this.

@coletdjnz
Copy link

Coming from ytdl-org/youtube-dl#29864, since I can't mention this on their issue tracker.

Appears to be a limitation of youtube-dl, and is probably unlikely to be fixed anytime soon.

For reference, the yt-dlp fork appears to extract this:

yt-dlp BJ_PrIVI5Ac -F                                                                               
[youtube] BJ_PrIVI5Ac: Downloading webpage
[youtube] BJ_PrIVI5Ac: Downloading android player API JSON
[info] Available formats for BJ_PrIVI5Ac:
ID    EXT  RESOLUTION FPS |  FILESIZE    TBR  PROTO | VCODEC        VBR  ACODEC     ABR  ASR    MORE INFO
----- ---- ---------- --- - ---------- ------ ----- - ----------- ------ --------- ---- ------- --------------------------------------------
139-0 m4a  audio only     |  784.17KiB   48k  https |                    mp4a.40.5  48k 22050Hz [en], English original, low, m4a_dash
139-1 m4a  audio only     |  784.17KiB   48k  https |                    mp4a.40.5  48k 22050Hz [en], English descriptive, low, m4a_dash
249-0 webm audio only     |  759.04KiB   47k  https |                    opus       47k 48000Hz [en], English original, low, webm_dash
249-1 webm audio only     |  787.40KiB   49k  https |                    opus       49k 48000Hz [en], English descriptive, low, webm_dash
250-0 webm audio only     |  981.74KiB   61k  https |                    opus       61k 48000Hz [en], English original, low, webm_dash
250-1 webm audio only     |  986.31KiB   61k  https |                    opus       61k 48000Hz [en], English descriptive, low, webm_dash
140-0 m4a  audio only     |  2.03MiB    129k  https |                    mp4a.40.2 129k 44100Hz [en], English descriptive, medium, m4a_dash
140-1 m4a  audio only     |  2.03MiB    129k  https |                    mp4a.40.2 129k 44100Hz [en], English original, medium, m4a_dash
251-0 webm audio only     |  1.90MiB    121k  https |                    opus      121k 48000Hz [en], English descriptive, medium, webm_dash
251-1 webm audio only     |  1.90MiB    121k  https |                    opus      121k 48000Hz [en], English original, medium, webm_dash
17    3gp  176x144    8   |  1.22MiB     78k  https | mp4v.20.3     78k  mp4a.40.2   0k 22050Hz 144p
160   mp4  256x144    30  |  1.90MiB    121k  https | avc1.4d400c  121k                         144p, mp4_dash
[...]

@clsid2
Copy link
Owner

clsid2 commented Aug 26, 2021

"English original" and "English descriptive" sound like names chosen by the creator of the video. So they could have theoretically been named just "A" and "B". So question becomes, how to know which audio track is the default/preferred one?

@ltguillaume
Copy link
Author

Thanks @coletdjnz I didn't know about the yt-dlp fork. So this output at least answers one question I posed in ytdl-org/youtube-dl#29864: apparently -0 and -1 are assigned arbitrarily (see 250-1 and 140-0, both "descriptive").

"English original" and "English descriptive" sound like names chosen by the creator of the video. So they could have theoretically been named just "A" and "B". So question becomes, how to know which audio track is the default/preferred one?

Could be, I have no idea. In that case it wouldn't really make sense to figure out why MPC-BE and YouTube-dl -f bestvideo+bestaudio choose the other stream (although perhaps MPC-BE just chooses the best video+audio combination stream when using YouTube-dl).

@clsid2
Copy link
Owner

clsid2 commented Aug 26, 2021

Looking at the page source, it contains this info for the audio streams:
"audioTrack":{"displayName":"English original","id":"en.4","audioIsDefault":true}
"audioTrack":{"displayName":"English descriptive","id":"en.2","audioIsDefault":false}

So audioIsDefault value would need to be extracted by YDL (or its forks).

@pukkandan
Copy link

Has been fixed in yt-dlp - yt-dlp/yt-dlp@26e8e04

$ yt-dlp -F BJ_PrIVI5Ac -v
[debug] Command-line config: ['-F', 'BJ_PrIVI5Ac', '-v']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.08.10 (source)
[debug] Plugin Extractors: ['SamplePlugin']
[debug] Git HEAD: 26e8e04454
[debug] Python version 3.9.6 (CPython 64bit) - Windows-10-10.0.19043-SP0
[debug] exe versions: ffmpeg n4.4-79-gde1132a891-20210809, ffprobe 2021-04-11-git-309e3cc15c-full_build-www.gyan.dev, phantomjs 2.1.1
[debug] Optional libraries: mutagen, pycryptodome, sqlite, websockets
[debug] Proxy map: {}
[debug] [youtube] Extracting URL: BJ_PrIVI5Ac
[youtube] BJ_PrIVI5Ac: Downloading webpage
[youtube] BJ_PrIVI5Ac: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, source, codec:vp9.2, size, br, lang
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, source, vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, lang, asr, proto, vext, aext, hasaud, id
[debug] Testing thumbnail 41
[info] Available formats for BJ_PrIVI5Ac:
ID    EXT  RESOLUTION FPS |  FILESIZE    TBR  PROTO | VCODEC        VBR  ACODEC     ABR  ASR    MORE INFO
----- ---- ---------- --- - ---------- ------ ----- - ----------- ------ --------- ---- ------- ---------------------------------------------------
139-0 m4a  audio only     |  784.17KiB   48k  https |                    mp4a.40.5  48k 22050Hz [en], English original (default), low, m4a_dash
139-1 m4a  audio only     |  784.17KiB   48k  https |                    mp4a.40.5  48k 22050Hz [en], English descriptive, low, m4a_dash
249-0 webm audio only     |  759.04KiB   47k  https |                    opus       47k 48000Hz [en], English original (default), low, webm_dash
249-1 webm audio only     |  787.40KiB   49k  https |                    opus       49k 48000Hz [en], English descriptive, low, webm_dash
250-0 webm audio only     |  981.74KiB   61k  https |                    opus       61k 48000Hz [en], English original (default), low, webm_dash
250-1 webm audio only     |  986.31KiB   61k  https |                    opus       61k 48000Hz [en], English descriptive, low, webm_dash
140-0 m4a  audio only     |  2.03MiB    129k  https |                    mp4a.40.2 129k 44100Hz [en], English descriptive, medium, m4a_dash
140-1 m4a  audio only     |  2.03MiB    129k  https |                    mp4a.40.2 129k 44100Hz [en], English original (default), medium, m4a_dash
251-0 webm audio only     |  1.90MiB    121k  https |                    opus      121k 48000Hz [en], English descriptive, medium, webm_dash
251-1 webm audio only     |  1.90MiB    121k  https |                    opus      121k 48000Hz [en], English original (default), medium, webm_dash
17    3gp  176x144    8   |  1.22MiB     78k  https | mp4v.20.3     78k  mp4a.40.2   0k 22050Hz 144p
160   mp4  256x144    30  |  1.90MiB    121k  https | avc1.4d400c  121k                         144p, mp4_dash
278   webm 256x144    30  |  1.68MiB    107k  https | vp9          107k                         144p, webm_dash
133   mp4  426x240    30  |  4.10MiB    261k  https | avc1.4d4015  261k                         240p, mp4_dash
242   webm 426x240    30  |  3.64MiB    232k  https | vp9          232k                         240p, webm_dash
134   mp4  640x360    30  |  9.14MiB    583k  https | avc1.4d401e  583k                         360p, mp4_dash
18    mp4  640x360    30  |  10.30MiB   657k  https | avc1.42001E  657k  mp4a.40.2   0k 44100Hz 360p
243   webm 640x360    30  |  6.62MiB    422k  https | vp9          422k                         360p, webm_dash
135   mp4  854x480    30  |  16.67MiB  1064k  https | avc1.4d401f 1064k                         480p, mp4_dash
244   webm 854x480    30  |  12.02MiB   767k  https | vp9          767k                         480p, webm_dash
136   mp4  1280x720   30  |  32.39MiB  2068k  https | avc1.64001f 2068k                         720p, mp4_dash
22    mp4  1280x720   30  |            2317k  https | avc1.64001F 2317k  mp4a.40.2   0k 44100Hz 720p
247   webm 1280x720   30  |  24.17MiB  1543k  https | vp9         1543k                         720p, webm_dash
137   mp4  1920x1080  30  |  63.00MiB  4022k  https | avc1.640028 4022k                         1080p, mp4_dash
248   webm 1920x1080  30  |  38.54MiB  2460k  https | vp9         2460k                         1080p, webm_dash
271   webm 2560x1440  30  |  108.63MiB 6936k  https | vp9         6936k                         1440p, webm_dash
313   webm 3840x2160  30  |  200.05MiB 12774k https | vp9         12774k                        2160p, webm_dash

Exited with code 0 in 7.760 sec

The language_preference key in the infojson will contain higher value for the default audio

@pukkandan
Copy link

pukkandan commented Aug 26, 2021

"English original" and "English descriptive" sound like names chosen by the creator of the video. So they could have theoretically been named just "A" and "B"

Dont think it is. I have seen other videos with the same description for the two streams

Eg:

$ yt-dlp -F WaOKSUlf4TM
[youtube] WaOKSUlf4TM: Downloading webpage
[youtube] WaOKSUlf4TM: Downloading android player API JSON
[youtube] WaOKSUlf4TM: Downloading android agegate player API JSON
[youtube] WaOKSUlf4TM: Downloading web agegate player API JSON
[info] Available formats for WaOKSUlf4TM:
ID    EXT  RESOLUTION FPS |  FILESIZE    TBR  PROTO | VCODEC          VBR  ACODEC     ABR  ASR    MORE INFO
----- ---- ---------- --- - ---------- ------ ----- - ------------- ------ --------- ---- ------- ---------------------------------------------------
139-0 m4a  audio only     |  885.42KiB   48k  https |                      mp4a.40.5  48k 22050Hz [en], English descriptive, low, m4a_dash
139-1 m4a  audio only     |  885.42KiB   48k  https |                      mp4a.40.5  48k 22050Hz [en], English original (default), low, m4a_dash
249-0 webm audio only     |  889.24KiB   49k  https |                      opus       49k 48000Hz [en], English descriptive, low, webm_dash
250-0 webm audio only     |  1.14MiB     64k  https |                      opus       64k 48000Hz [en], English descriptive, low, webm_dash
249-1 webm audio only     |  877.56KiB   48k  https |                      opus       48k 48000Hz [en], English original (default), low, webm_dash
250-1 webm audio only     |  1.13MiB     64k  https |                      opus       64k 48000Hz [en], English original (default), low, webm_dash
140-0 m4a  audio only     |  2.29MiB    129k  https |                      mp4a.40.2 129k 44100Hz [en], English descriptive, medium, m4a_dash
140-1 m4a  audio only     |  2.29MiB    129k  https |                      mp4a.40.2 129k 44100Hz [en], English original (default), medium, m4a_dash
251-0 webm audio only     |  2.27MiB    128k  https |                      opus      128k 48000Hz [en], English descriptive, medium, webm_dash
251-1 webm audio only     |  2.26MiB    127k  https |                      opus      127k 48000Hz [en], English original (default), medium, webm_dash
17    3gp  176x144    8   |  1.39MiB     78k  https | mp4v.20.3       78k  mp4a.40.2   0k 22050Hz 144p
394   mp4  256x144    30  |  1.14MiB     64k  https | av01.0.00M.08   64k                         144p, mp4_dash
160   mp4  256x144    30  |  1.01MiB     56k  https | avc1.4d400c     56k                         144p, mp4_dash
278   webm 256x144    30  |  1.38MiB     78k  https | vp9             78k                         144p, webm_dash
395   mp4  426x240    30  |  2.18MiB    123k  https | av01.0.00M.08  123k                         240p, mp4_dash
133   mp4  426x240    30  |  2.18MiB    123k  https | avc1.4d4015    123k                         240p, mp4_dash
242   webm 426x240    30  |  2.58MiB    145k  https | vp9            145k                         240p, webm_dash
396   mp4  640x360    30  |  4.43MiB    250k  https | av01.0.01M.08  250k                         360p, mp4_dash
134   mp4  640x360    30  |  4.29MiB    242k  https | avc1.4d401e    242k                         360p, mp4_dash
18    mp4  640x360    30  |  10.32MiB   582k  https | avc1.42001E    582k  mp4a.40.2   0k 44100Hz 360p
243   webm 640x360    30  |  5.54MiB    312k  https | vp9            312k                         360p, webm_dash
397   mp4  854x480    30  |  8.13MiB    459k  https | av01.0.04M.08  459k                         480p, mp4_dash
135   mp4  854x480    30  |  7.11MiB    401k  https | avc1.4d401f    401k                         480p, mp4_dash
244   webm 854x480    30  |  9.96MiB    563k  https | vp9            563k                         480p, webm_dash
398   mp4  1280x720   30  |  16.62MiB   939k  https | av01.0.05M.08  939k                         720p, mp4_dash
136   mp4  1280x720   30  |  11.98MiB   677k  https | avc1.4d401f    677k                         720p, mp4_dash
22    mp4  1280x720   30  |            2287k  https | avc1.64001F   2287k  mp4a.40.2   0k 44100Hz 720p
247   webm 1280x720   30  |  19.67MiB  1111k  https | vp9           1111k                         720p, webm_dash
399   mp4  1920x1080  30  |  30.05MiB  1698k  https | av01.0.08M.08 1698k                         1080p, mp4_dash
137   mp4  1920x1080  30  |  39.80MiB  2249k  https | avc1.640028   2249k                         1080p, mp4_dash
248   webm 1920x1080  30  |  35.69MiB  2016k  https | vp9           2016k                         1080p, webm_dash
400   mp4  2560x1440  30  |  86.39MiB  4882k  https | av01.0.12M.08 4882k                         1440p, mp4_dash
271   webm 2560x1440  30  |  97.87MiB  5531k  https | vp9           5531k                         1440p, webm_dash
401   mp4  3840x2160  30  |  176.14MiB 9954k  https | av01.0.12M.08 9954k                         2160p, mp4_dash
313   webm 3840x2160  30  |  240.13MiB 13570k https | vp9           13570k                        2160p, webm_dash

Lesmiscore added a commit to ytdl-patched/ytdl-patched that referenced this issue Aug 26, 2021
* 'master' of https://github.com/yt-dlp/yt-dlp:
  [youtube] Improve 26e8e04
  [youtube] Prefer audio stream that YouTube considers default Fixes: ytdl-org/youtube-dl#29864 Related: clsid2/mpc-hc#1268
  [FormatSort] Remove priority of `lang`
@ltguillaume
Copy link
Author

Great stuff @pukkandan, thanks!

@clsid2
Copy link
Owner

clsid2 commented Sep 3, 2021

MPC-HC now uses the track preference info when available.

@ObjectInSpace
Copy link

It would be amazing to be able to pick the descriptive audio track from within MPC-HC! Can this be done?

@ObjectInSpace
Copy link

This would be really useful for folks like myself who use descriptive audio tracks, and might be a compelling reason for others to switch from what they currently use. (AFAIK most are using Foobar+foo_youtube but I am pretty sure it cannot do this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants