pixeltris / TwitchAdSolutions

7.25k stars 425 forks source link

vaft issues (freezing / paused / playback problems) #164

Open TsukiZero opened 1 year ago

TsukiZero commented 1 year ago

They might be tied to ads, but sometimes the video freeze and the audio keeps going, when this happens the quality changes from whatever it was to 360p for a moment or until the player is reset.

With "Video Swap New" it causes the quality to change completely from whatever to 360p but the frames stops freezing.

MonfGeiger commented 11 months ago

I can confirm this. im currently watching a live LaynaLazar stream right now at the time of this comment, and i can confirm random frame freezes, on top of a video quality issue and a total video freeze

TsukiZero commented 11 months ago

This issue still persists in the new build.

pixeltris commented 11 months ago

Correct. I'm not working on fixes for the freezing issues.

TsukiZero commented 11 months ago

No idea on solutions either?

Zero3K commented 10 months ago

Any updates?

TsukiZero commented 10 months ago

No fix yet, no one looking into it apparently.

izar3 commented 4 months ago

This has something to do with bad connection when ads start. It does not happen if your connection is stable and have low latency

I have tested this while an ad is playing, dropping my connection in and out and it will always swap to source > 360p > source > Freeze

My testing on #222 findReactNode() was broken and lead to incorrect results but if you remove this function in the latest build there is no freezing during ads even if your connection is unstable

so.. is there a way to change the alt player/m3u8 when ads are showing to 720p or source quality or another solution?

pixeltris commented 4 months ago

Under vaft every time the Twitch player requests the m3u8 it requests 3 different m3u8 player types. The first two have source quality. The last doesn't. This is already pretty aggressive at trying to get the source quality. If you'd like to be more aggressive you could add a fourth request.

https://github.com/pixeltris/TwitchAdSolutions/blob/7a8fa9923ca0fac8ed293d396898eea5124c616a/vaft/vaft.user.js#L293-L296

Replace with:

weaverText = await processM3U8(url, responseText, realFetch, 'site');
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType2);
}
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
}

This requests the main 'site' player type twice but the second one will get a new access token which can sometimes get you a clean stream faster. This constant swapping of the active m3u8 is the reason for that player pause/play / findReactNode() stuff to circumvent freezing.

Also see Purple AdBlock which is also pretty aggressive at requesting different player types https://github.com/arthurbolsoni/Purple-adblock/blob/main/serviceWorker/src/modules/stream/interface/stream.enum.ts

If this isn't good enough then you are looking for a proxy solution. See TTV LOL PRO https://github.com/younesaassila/ttv-lol-pro

izar3 commented 4 months ago

https://github.com/pixeltris/TwitchAdSolutions/blob/7a8fa9923ca0fac8ed293d396898eea5124c616a/vaft/vaft.user.js#L293-L296

Replace with:

weaverText = await processM3U8(url, responseText, realFetch, 'site');
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType2);
}
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
}

I tested this for 4~ hrs with midrolls every 30-60 mins and this works way better

The only time I have seen it pause/play is at the start of a midroll but it's instant and always finds clean segments at source quality

ty pixeltris

TsukiZero commented 3 months ago

So, the bug is back, that patch does nothing.