yt-dlp eats multivariant HLS playlists - proposed solution included
tracked

TapGhoul
- Open a multivariant playlist in avpro in-game - most playlists from https://hlsjs.video-dev.org/demo/ will work. https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8 for example.
- Notice you have no audio.
What appears to be happening is yt-dlp is always picking the first applicable HLS stream, recursing until it finds something with actual video. As a result, it can result in selecting an m3u8 that is invalid. It is also part of what causes VRChat to be unable to play youtube videos at high quality, thus needing a custom yt-dlp fork.
One solution I can suggest is having yt-dlp standard (or a fork still, but closer to standard) be used to construct multiple URLs - --get-url results in multiple lines returned in these cases, still abiding by filters, though -J is likely more ideal here as it will output all info at once, you'll just need to filter in your own logic rather than passing the filter into yt-dlp's command line.
For actually playing back - and then constructing a temporary .m3u8 in the format of:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="audio",AUTOSELECT=YES,URI="<full audio m3u8 url>"
#EXT-X-STREAM-INF:BANDWIDTH=<video *max* bandwidth>,AUDIO="audio"
<full video m3u8 url>
This has been tested on windows and it plays back correctly. For example:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="audio",AUTOSELECT=YES,URI="https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa_audio_1_stereo_128000.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=628000,AUDIO="audio"
https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa_video_180_250000.m3u8
Using yt-dlp standard with JSON, the video bitrate can be extracted from the tbr field - it's in kbps, so just multiply by 1000 and make it an integer and HLS will take it.
Using AVPro's MediaPlayer::OpenMediaFromBuffer() call can take this HLS playlist directly, which is useful for both security (time-of-use related stuff) and general performance.
The proposed HLS playlists are the minimum required to get proper consistent playback. As per spec, BANDWIDTH needs to be set to the maximum bitrate, not the average, to allow buffers to be allocated large enough for smooth playback, and is a required tag to operate - but it'll survive if it's not perfectly accurate, tbr is a good enough value to use.
Log In
Activity Feed
Sort by

StormRel
tracked

TapGhoul
Update the second: it looks like WMF can't handle however youtube encodes audio for m3u8, so this may not be applicable to youtube specifically unfortunately. However, the general issue with HLS is still a problem, and it is something I'd love to see something here improved - the sample files work just fine.

Haxy
Wmf also can't handle vp9 in the context of a hls playlist for some reason, Microsoft needs to fix wmf honestly..

TapGhoul
Quick update: one change after further testing with fragmented. Slight adjustment to the playlists, this works with more types of underlying multivariant playlists - though in many cases this is unnecessary, and may cause additional unwanted load.
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="audio",AUTOSELECT=YES,URI="<full audio m3u8 url>"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="video",NAME="video",AUTOSELECT=YES,URI="<full video m3u8 url>"
#EXT-X-STREAM-INF:BANDWIDTH=<video *max* bandwidth>,AUDIO="audio",VIDEO="video"
<full video m3u8 url>
Example:
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="audio",AUTOSELECT=YES,URI="https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa_audio_1_stereo_128000.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="video",NAME="video",AUTOSELECT=YES,URI="https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa_video_180_250000.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=628000,AUDIO="audio",VIDEO="video"
https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa_video_180_250000.m3u8
I am unsure if you can just switch out the main playlist - it needs something there, but by overriding audio/video, avpro correctly loads in the current mentioned build of VRChat without issue, and plays back .m4s without any audio stutters (though the lack of stutter may just be my sample, I haven't tested on a wide enough array of files just yet).