Skip to content

stream.hls: add --hls-segment-queue-threshold #5478

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

Resolves #5476

Descriptions in the commit messages.

Second commit increases the value from 2 to 3, which is a bit more lenient, so unstable live streams don't cause unnecessary interruptions. This comes at the cost of stable live streams without an endlist tag being stopped a bit later.

Not sure if the name of the CLI-argument and session-option makes sense and if there's a better one that's easier to understand.


As a reminder:
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.

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.

Not sure if the name of the CLI-argument and session-option makes sense and if there's a better one that's easier to understand.

Hmm, I agree with you that I'm not sure if the naming makes sense either but I also can't think of something better which accurately describes what is happening. I think your longer explanation in the argparser does a good job of explaining what is occurring and realistically I don't see that many users modifying this setting themselves without some knowledge of what is going on so it should be okay. 👍

@Lytexx
Copy link

Lytexx commented Aug 4, 2023

@bastimeyer
i ran both 6.0.1 and this PR on the same stream at the same time

the 6.0.1 one eventually failed with this error

stream.hls][warning] No new segments in playlist for more than 2.00s. Stopping...

the m3u8 of youtube streams using ultra low latency mode seem to have set a target duration of 1

the one running this PR using --hls-segment-queue-threshold 0 kept running

@bastimeyer
Copy link
Member Author

Could you please link one of those YT live streams?

@Lytexx
Copy link

Lytexx commented Aug 4, 2023

Could you please link one of those YT live streams?

sure, i used this one https://www.youtube.com/watch?v=mgBKCSJZtdc
you can see which latency a streamer has set in the "stats for nerds" thing that you can open with right click on the player

@bastimeyer
Copy link
Member Author

#EXT-X-TARGETDURATION:1
#EXTINF:1.0,

That's some very aggressive playlist polling. The current HLS spec is not designed for this, hence the addition of actual low-latency streams in the latest HLS spec revisions that have not been finalized yet.

The default value of 3 should be fine though IMO. I'm also thinking about adding a lower boundary regardless the targetduration, so nonsense value like this can get ignored. Maybe something like 5 seconds.

Allow users to customize the segment queue timing threshold which checks
whether to stop the stream early if no new segments were queued after
the playlist's target-duration multiplied by the queue-threshold-factor
has passed.
Increase the default value from 2 to 3, so that the default
configuration doesn't unnecessarily cause issues in certain live streams
where the connection of the broadcaster is unstable and the streaming
provider doesn't or can't queue new segments.

Try to keep this value reasonably low, so we can still stop streams
early when the `EXT-X-ENDLIST` tag is missing.
Wait for at least 5 seconds before stopping early, regardless of
the playlist's targetduration and hls-segment-queue-threshold value
@bastimeyer bastimeyer force-pushed the stream/hls/segment-queue-threshold branch from a3add92 to 7e7d7b4 Compare August 4, 2023 21:05
@bastimeyer bastimeyer merged commit 3a38ca2 into streamlink:master Aug 4, 2023
@bastimeyer bastimeyer deleted the stream/hls/segment-queue-threshold branch August 4, 2023 21:11
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: Could the "No new segments in playlist" judgment be longer or customizable?
3 participants