Skip to content

stream.hls: reload playlist in strict intervals #5321

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

Make HLSStreamWorker reload the playlist in strict time intervals instead of just queuing the next playlist reload.

Previously, playlist fetch time and segment processing time always added to the overall reload time, resulting in an eventual shift of the expected reload time, which could lead to an empty segment queue in certain scenarios (live-edge=1 or Twitch low latency streaming).

When the reload time exceeds the expected reload interval, continue with the shifted interval, which matches the old behavior.


Resolves #4646

When the reload time exceeds the expected reload interval, continue with the shifted interval, which matches the old behavior.

That could be changed, so that if a playlist reload takes too long, the next one could start immediately. I am not sure though if that's a good idea, because depending on the response data and the timing of when the data was generated by the server, no new segments could be included in the next response. And if one request takes more than two intervals, then the next x playlist reloads will be done immediately one after another, and that doesn't sound right.

Opening this as a draft for now, because I want to test this a bit first...

Tests are a bit complicated, but that's because of the playlist reload iteration with the timing involved, and that's always messy. I tried to write this as comprehensible as possible.


The timestamps of the playlist reloads now don't get shifted (example with playlist reload time of 2s):

[13:32:39.553732][stream.hls][debug] Reloading playlist
...
[13:35:09.553753][stream.hls][debug] Reloading playlist

master:

[13:35:36.733978][stream.hls][debug] Reloading playlist
...
[13:37:56.415168][stream.hls][debug] Reloading playlist

@bastimeyer bastimeyer marked this pull request as ready for review May 3, 2023 05:20
Make `HLSStreamWorker` reload the playlist in strict time intervals
instead of just queuing the next playlist reload.

Previously, playlist fetch time and segment processing time always added
to the overall reload time, resulting in an eventual shift of the
expected reload time, which could lead to an empty segment queue
in certain scenarios (live-edge=1 or Twitch low latency streaming).

When the reload time exceeds the expected reload interval, continue
with the shifted interval, which matches the old behavior.
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.

Looks good to me, I assume this is ready to go since you moved it out of draft but since there's no additional comment I'll mark it as approved and you can merge it if you're satisfied with everything.

@bastimeyer
Copy link
Member Author

I want to publish a new release for the urllib3 issue first, without these changes here

@bastimeyer bastimeyer merged commit 25efd36 into streamlink:master May 6, 2023
@bastimeyer bastimeyer deleted the stream/hls/strict-reload-interval branch May 6, 2023 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stream.hls: smarter playlist reload times
2 participants