Skip to content

stream.hls: fix endlist on empty playlist reload #5538

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

Conversation

bastimeyer
Copy link
Member

Fixes #5536

@Hakkin Please give it a try. Thanks!

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.

Approved pending fix confirmation from reporter.

@Hakkin
Copy link
Contributor

Hakkin commented Sep 6, 2023

This seems to have fixed it. I was having a lot of trouble reproducing this issue with Twitch streams, so if you'd like to test it yourself, I found it easier to generate a short HLS playlist using ffmpeg, create a copy with #EXT-X-ENDLIST removed, then play the playlist with streamlink and manually swap them during playback.

$ ffmpeg -i input.mp4 -c copy -hls_time 2 -hls_list_size 0 output/index_endlist.m3u8
$ sed 's/#EXT-X-ENDLIST$//' output/index_endlist.m3u8 > output/index.m3u8
$ streamlink -o /dev/null --hls-live-restart --hls-segment-queue-threshold=0.0 --hls-playlist-reload-time=segment --stream-timeout=240.0 --loglevel=all --logfile=log.txt "file://./output/index.m3u8" best &\
sleep 10 &&\
mv output/index_endlist.m3u8 output/index.m3u8 &&\
time wait

In the git master version, this will hang until stream-timeout is hit, with this commit it ends right away after the playlist swap.

@bastimeyer
Copy link
Member Author

I was having a lot of trouble reproducing this issue

That's what the added test is for. The added test alone fails without the changes in the HLSStreamWorker.

Thanks for validating on non-test data though. Going to merge new.

@bastimeyer bastimeyer merged commit 02bd131 into streamlink:master Sep 6, 2023
@bastimeyer bastimeyer deleted the stream/hls/fix-endlist-on-empty-reload branch September 6, 2023 22:29
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.

HLS streams sometimes fail to end after encountering #EXT-X-ENDLIST
3 participants