Skip to content

plugins.twitch: rewrite disable ads logic #2895

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

Merged

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Apr 14, 2020

Resolves #2894

Simply filters out segments that are annotated with #EXTINF:2.002,Amazon[...].
--twitch-disable-ads needs to be set, just like before.

edit:
Well, it doesn't "resolve" the issue, just replaces the --twitch-disable-ads logic with new one. As I've mentioned in the linked thread, Twitch's webplayer is not showing any ads to me and I haven't figured out yet why. If someone knows how to "trick" Twitch into providing the real stream data, then that would be considered the real "fix" for the issue. Nevertheless, the parameter needs new filtering logic.


The stream discontinuities when the "ad" switches to the regular stream data seems to be causing a lot of issues in various players, especially VLC (no idea about the used version though). Maybe we should re-evaluate switching the default player to MPV (#2144), as it's working just fine there.

@bastimeyer bastimeyer added the plugin issue A Plugin does not work correctly label Apr 14, 2020
@codecov
Copy link

codecov bot commented Apr 14, 2020

Codecov Report

Merging #2895 into master will decrease coverage by 0.08%.
The diff coverage is 96.96%.

@@            Coverage Diff             @@
##           master    #2895      +/-   ##
==========================================
- Coverage   52.68%   52.59%   -0.09%     
==========================================
  Files         252      250       -2     
  Lines       15769    15715      -54     
==========================================
- Hits         8308     8266      -42     
+ Misses       7461     7449      -12     

@bastimeyer bastimeyer added the WIP Work in process label Apr 14, 2020
@gravyboat
Copy link
Member

gravyboat commented Apr 14, 2020

I'm able to get ads every time in a Chrome Incognito window (logged out) but I don't see anything particularly useful past what you're seeing here. What data do you want? I don't know if there is any way to trick Twitch in this sense as it looks to me like they either present an ad, or they present the commercial break notification, there's no stream data to pull.

It seems to me like the big issue with players is being caused by buffering. They're not sending any stream data prior to the commercial break ending, so when it does end that's when you finally get stream data and it causes problems for the player because nothing is cached. It behaves similarly to when I was experimenting with extreme low latency live edge settings. I am fine with making MPV the default suggested player, but the issues brought up by people still have not been addressed in any way by the MPV team. The lack of official builds being by far my biggest concern.

@bastimeyer bastimeyer force-pushed the plugins/twitch/rewrite-disable-ads branch from b637bb0 to 2ad5293 Compare April 15, 2020 00:13
@bastimeyer bastimeyer removed the WIP Work in process label Apr 15, 2020
@bastimeyer bastimeyer force-pushed the plugins/twitch/rewrite-disable-ads branch from 2ad5293 to 88800dc Compare April 15, 2020 00:16
@bastimeyer
Copy link
Member Author

@gravyboat It's possible that ads are not shown to logged in users. Doesn't help Streamlink though, as we can't use any auth data when acquiring the access token (users can still set a custom auth HTTP header I believe).

Regarding MPV, I don't have an answer here. My points from the linked issue still stand, I guess.


Pushed another clean up commit. This should be in a better shape overall now.
If there are preroll ads, another info message will be logged. I think this is better than just saying "Will ignore ad segments".

@gravyboat
Copy link
Member

I like the updated comment @bastimeyer, makes it more clear regarding what is going on.

@bastimeyer bastimeyer force-pushed the plugins/twitch/rewrite-disable-ads branch from 88800dc to 65a8ab2 Compare April 15, 2020 00:53
@bastimeyer
Copy link
Member Author

There might be a problem with the current implementation. I didn't run into non-preroll ads yesterday (pre-roll ads were filtered out just fine), but it's possible that Twitch requires HLS clients to still download the segments, like mentioned last year here:
#2372 (comment)

That would mean that the filtering can't be done in the parser anymore and the removal of the custom StreamWriter has to be reverted.

Unfortunately, this can't be tested right now as the embedded ads have stopped.

@bastimeyer
Copy link
Member Author

Reverted the custom StreamWriter removal. Ad segments will now be always downloaded and then discarded afterwards.


Even if Twitch currently doesn't embed ads, it's safe to assume that this new system will be used in the future. Since this PR doesn't only implement the new ad filtering logic, but also removes the unnecessary restriction that low latency streaming and ads filter can't be used at the same time, I'd like to see this being included in the next release.

Being able to always set the low latency streaming parameter, even for non-LL streams, is a good thing, because it overrides the default playlist refresh timer, which is stupid IMO. The default refresh time is 6 seconds and causes 3 whole segments to be queued each time, meaning that with a default live edge value of 3, a short hickup while refreshing the playlist may cause a hickup in the playback if the player's own cache isn't large enough. And short delays while reloading the playlist happen a lot.

This makes me wonder whether a parameter for manually overriding the refresh time would make sense, maybe with support for both static time values and keywords like min-segment-length or so.

@gravyboat
Copy link
Member

gravyboat commented Apr 19, 2020

@bastimeyer I agree. There's no reason not to include it and it will save us time going forward from answering repetitive questions. It has no negative impact. I really like the idea of adding an option to manually override the refresh timer, I've run in to this myself where I git a hiccup just because it's waiting for the playlist to update a bit after opening a stream.

@bastimeyer bastimeyer force-pushed the plugins/twitch/rewrite-disable-ads branch from c714a86 to 46ebafc Compare April 20, 2020 17:20
@bastimeyer
Copy link
Member Author

Noticed some "incorrect" values in the tests which are now fixed and also patched the HLSStreamWorker's wait method, so that the tests run without unnecessarily waiting between playlist refreshes.

@gravyboat gravyboat merged commit 1e8df7a into streamlink:master Apr 21, 2020
@bastimeyer bastimeyer deleted the plugins/twitch/rewrite-disable-ads branch January 19, 2021 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin issue A Plugin does not work correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Twitch streams showing Commercial Break In Progress video
4 participants