-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
plugins.twitch: fix ad filtering bug #5007
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
plugins.twitch: fix ad filtering bug #5007
Conversation
@phxn Could you please check and see if this resolves the issue for you? |
Twitch doesn't include duration data for prefetch segments, which means when more than one prefetch segment is included in the HLS playlist, the start time of the second (or third) prefetch segment has to be guessed from the duration of the regular segments. This is done by calculating the average of all available regular segments and using that as an offset of the last regular segment for each prefetch segment. This however can cause issues when segment durations vary a lot and the start time of an annotated ad block doesn't match the extrapolated start time of the first ad segment due to the miscalculation. The ad segment then gets incorrectly included in the output stream. Since a discontinuity tag is always present, even between prefetch tags with ads, we can make use of it and treat prefetch segments after a discontinuity tag as ads. This won't cause any issues during the transition to the regular stream content, as it only affects the logic of prefetch segments.
c40cba8
to
c62be03
Compare
Nice thanks, where can I download the Windows 64bit executable? |
You can't, because it's a pull request. |
Alternatively, side-load the plugin changes |
Thanks, I've side-loaded and will see how it goes. EDIT: Still seeing the purple screen. It's really not a big deal for me because the stream will be interrupted either way, so don't stress too much over it. I'm seriously considering buying Turbo to just remove the ads permanently but I hate that I'm being pushed that way due to their aggressive ad campaign. |
Post the full debug log ( The issue which gets fixed in this PR is an edge case and it's specific to channels which have a variable duration of HLS segments while low latency streaming, which is not too common. The main issue already got fixed in 5.1.0 by #4942. I have checked several dozens of streams with pre-roll and mid-roll ads, and they all get filtered out correctly without any issues. If you have a reliable way of reproducing a bug while filtering out ads ("purple screens"), then post the log output, as mentioned. This PR should be fine though. I will merge this now, so that the changes can be included in the Windows and Linux AppImage nightly builds, which will trigger in an hour or so. |
I created a folder called plugins in my %appdata%\streamlink folder, in there I created a twitch.py from this: It's created a "pycache" folder within the plugins folder so I think it's working. Tried the log thing, got this at the top: [23:43:19.610492][session][debug] Plugin twitch is being overridden by C:\Users<USER>\AppData\Roaming\streamlink\plugins\twitch.py Just saw another purple screen on shrouds stream. |
Once again, this is not a useful statement without a full log output on the "debug" or "all" log level. You could be running literally anything. If you're running the latest version, which the debug log will tell you, and without having made any modifications, then there should be no issues. If there are issues for whatever reason, then the log output will show this. If you're unable to provide a full log output where a filtering issue occurred, then nobody will be able to fix any potential issues. I have just tested shroud's stream, which btw is not a low latency stream, and both pre-roll and mid-roll ads get filtered out correctly. |
|
You're completely bypassing Streamlink and just using it as an HLS URL resolver. Your player is doing all the work, not Streamlink, and your player is not able to filter out ads. If you don't know what a specific parameter does, then don't use it. https://streamlink.github.io/cli.html#cmdoption-player-passthrough
|
I see, I think I started using it because I couldn't get more than 1 stream to play at a time without using HLS. Found some info on that now here https://github.com/streamlink/streamlink-twitch-gui/wiki/Player-configuration |
Hello, I'm having an issue where the player (vlc & mpv) will pause for 30 seconds to a minute and then resume the stream. This happens maybe 45 minutes to an hour into a stream. I'm unsure if this is the intended outcome with this merge or not. Below is my log file with loglevel all. I removed my oauth string. I closed the stream shortly after the pause happened. So maybe what you need to know is towards the end of the log. Thanks. |
Read this |
Twitch doesn't include duration data for prefetch segments, which means when more than one prefetch segment is included in the HLS playlist, the start time of the second (or third) prefetch segment has to be guessed from the duration of the regular segments. This is done by calculating the average of all available regular segments and using that as an offset of the last regular segment for each prefetch segment.
This however can cause issues when segment durations vary a lot and the start time of an annotated ad block doesn't match the extrapolated start time of the first ad segment due to the miscalculation. The ad segment then gets incorrectly included in the output stream.
Since a discontinuity tag is always present, even between prefetch tags with ads, we can make use of it and treat prefetch segments after a discontinuity tag as ads. This won't cause any issues during the transition to the regular stream content, as it only affects the logic of prefetch segments.
Resolves #5006
Don't merge yet, I will need to run further tests on live data.
Once the fix got merged, I'll be preparing a new bugfix release.