Skip to content

plugins.twitch: log ad breaks with duration #6051

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

This logs Twitch's ad breaks and their respective durations, which is especially useful if --twitch-disable-ads is set, so users will know how long the output will be paused for.

Everyone's invited to give this a test:
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#pull-request-feedback


This implementation caches the ad-break's X-TV-TWITCH-AD-COMMERCIAL-ID metadata in order to avoid logging multiple parts of the same ad break. This is because multiple EXT-X-DATERANGE tags can be inserted into the HLS playlists one after another, e.g. when multiple "ad-break-in-progress" placeholder loops are being shown in a row, or distinct "actual ads" are shown if enabled via --twitch-access-token-param=playerType=web (we default to "embed" so we only see the placeholders). Those ad-part date-ranges always share the ID of the whole ad break and always include the full duration via the X-TV-TWITCH-AD-POD-FILLED-DURATION metadata, so when the full ad break is 90s, it only logs it once instead of logging "30s" three times when there are three EXT-X-DATERANGE tags. There's also metadata for the number of parts in a break and the current part number, but this is irrelevant since we're only interested in the full duration which we only want to log once.


Prerolls + midrolls

[plugins.twitch][info] Will skip ad segments
[plugins.twitch][info] Low latency streaming (HLS live edge: 2)
[plugins.twitch][info] Waiting for pre-roll ads to finish, be patient
[plugins.twitch][info] Detected advertisement break of 15 seconds
[stream.hls][info] Filtering out segments and pausing stream output
[stream.hls][info] Resuming stream output
[plugins.twitch][info] Detected advertisement break of 90 seconds
[stream.hls][info] Filtering out segments and pausing stream output
[stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[stream.hls][info] Resuming stream output

No prerolls

[plugins.twitch][info] Will skip ad segments
[plugins.twitch][info] Low latency streaming (HLS live edge: 2)
[plugins.twitch][info] Detected advertisement break of 120 seconds
[stream.hls][info] Filtering out segments and pausing stream output
[stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[stream.hls][info] Resuming stream output
[plugins.twitch][info] Detected advertisement break of 120 seconds
[stream.hls][info] Filtering out segments and pausing stream output
[stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[stream.hls][info] Resuming stream output

@bastimeyer bastimeyer added the plugin enhancement A new feature for a working Plugin label Jun 25, 2024
Copy link
Member

@gravyboat gravyboat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good idea. This is a nice quality of life change.

@bastimeyer bastimeyer force-pushed the plugins/twitch/log-ads-duration branch from a59ee0a to 2bbfd08 Compare June 28, 2024 21:03
@bastimeyer bastimeyer merged commit 29a3107 into streamlink:master Jun 28, 2024
23 checks passed
@bastimeyer bastimeyer deleted the plugins/twitch/log-ads-duration branch June 28, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin enhancement A new feature for a working Plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants