smplayer-dev / smplayer

Free Media Player for Windows, Linux and Mac OS with YouTube support.
https://smplayer.info
GNU General Public License v2.0
655 stars 92 forks source link

Twitch low latency stream support #735

Open raszpl opened 1 year ago

raszpl commented 1 year ago

Is your feature request related to a problem? Please describe. Just by accident I ran smplayer.exe https://www.twitch.tv/beagsandjam and discovered its working :o I think smplayer just passes url to mpv and mpv leverages ytdl. Yay! Still that gives us stream delayed by ~4 seconds.

Describe the solution you'd like streamlink has a solution for that: https://streamlink.github.io/cli.html#cmdoption-twitch-low-latency

SMPlayer\mpv>streamlink-5.5.1-2-py38-x86_64\bin\streamlink.exe https://www.twitch.tv/beagsandjam best --player mpv --twitch-low-latency --hls-live-edge 1

this actually gives you lower latency than the real twitch website in low latency mode :o No idea how this works, but would be neat if it turned out easy to implement and smplayer replicated it.

e-d-n-a commented 11 months ago

Not sure, but maybe the setting "Cache for streams" (under Preferences-Performance-Cache) is related and should have some effect on the delay, if you set it to lower values (e.g. 512 kB)!?

It translates to the mpv-setting "--demuxer-max-bytes=...", which can be confirmed from the MPV-log. Might be introducing some stuttering in the playback though. You can test it.

When I play a stream twice in SMPlayer (with 512kB or 2048kB Cache) and in Streamlink with your settings from above: streamlink.exe https://www.twitch.tv/[some channel] best --player mpv --twitch-low-latency --hls-live-edge 1 , then I have a delay of ~+6s in SMPlayer/MPV compared to Streamlink/MPV [Stream: 1080p60]. Both use the same mpv.exe and with both cache settings it's the same result.

raszpl commented 11 months ago

Afaik "Cache for streams" just sets initial condition by delaying playback until accumulating x bytes, you can actually fast forward to the front of the stream to the point you will get stuttering when download doesnt keep up with playback, even with huge cache setting

Streamlink somehow requests lower latency version of .m3u8 url from twitch API.