Skip to content
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

stream.hls: stop stream early on missing segments #5330

Conversation

bastimeyer
Copy link
Member

Stop the stream early if no new segments were queued by the worker after the playlist's targetduration * 2 has passed.

Use the timing factor of 2 to prevent potential issues with the reload timing of the playlist or when a stream discontinuity occurs.


https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.3.1

The EXT-X-TARGETDURATION tag specifies the maximum Media Segment duration.
The EXTINF duration of each Media Segment in the Playlist file, when rounded to the nearest integer, MUST be less than or equal to the target duration; longer segments can trigger playback stalls or other errors. It applies to the entire Playlist file.


Resolves #2198
See #2198 (comment)

Before this can get merged, lots of testing with real-world data needs to be done. Stopping the stream early when there's no reason for it would be pretty bad.

These changes don't affect ad filtering, because this is done in the worker thread where it doesn't write the data to the output buffer. Ad segments still get queued by the worker, so the queue timing threshold won't be reached by filtering out ads.

Please help me test this.

bastimeyer added 2 commits May 6, 2023 07:59
Rename attibute for consistency reasons and change its type to float,
despite RFC 8216 describing it as an integer (permissive parsing).
Stop the stream early if no new segments were queued by the worker after
the playlist's `targetduration * 2` has passed.

Use the timing factor of `2` to prevent potential issues with
the reload timing of the playlist or when a stream discontinuity occurs.
@bastimeyer bastimeyer changed the title stream.hls: rename M3U8.targetduration attribute stream.hls: stop stream early on missing segments May 6, 2023
@bastimeyer bastimeyer marked this pull request as ready for review May 21, 2023 11:08
@bastimeyer bastimeyer merged commit 3ea8b9f into streamlink:master May 21, 2023
@bastimeyer bastimeyer deleted the stream/hls/segment-queue-timing-threshold branch May 21, 2023 11:09
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: stop stream early when EXT-X-ENDLIST is missing
1 participant