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

Fix already processed fragments being recognised as new due to change of base fragments url #51

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

15532th
Copy link
Contributor

@15532th 15532th commented Jan 7, 2024

Same fragments might get different urls on a different worker server on two consecutive updates of hls playlist. HLSDownloader._fill_queue relies on comparison of full fragment urls to pick new ones, so when this happens it will treat all urls from the current playlist chunk as new, which will cause about ten fragments to get downloaded for a second time, leading to about a ten seconds segment of the video being repeated twice in the recording.

Here is an example of two different urls pointing to fragment with the same number and seemingly the same content:

https://us-west-1-media-worker1036.live.fc2.com/a/stream/v3/24678502/52/data/73436.ts?time=1703265219&hash=67345c5328fe0ebb54e35c3c1614d340625c55f264ffc66248879583423d2e3a
https://us-west-1-media-worker1035.live.fc2.com/a/stream/v3/24678502/52/data/73436.ts?time=1703265219&hash=2354e75fddf69a76f6f5b8337b880fa992ae42a15e4ddb6f9d077760bee1a54d

This PR makes it that only filename part of the fragment url (73436.ts for the links above) is used for comparison, which fixes the issue.

Currently there is no warning issued when it happens, but it can still be detected by [hls] Found 12 new fragments line in output. Perhaps some dedicated debug message should be added?

The same fragment might have different urls on two consequent updates of
hls playlist, in which case last_fragment exact value will not be
found in the urls list, which will lead to new_idx being set to zero and
already processed fragments being downloaded for a second time.

To deal with this instead of full fragments urls only filename parts are
used for comparison, since they only contain fragment number, which is
unique for a given fragment and doesn't change.
@hizkifw
Copy link
Member

hizkifw commented Jan 8, 2024

Thanks! I've been wondering why some of my recordings have repeated segments, but looks like this is the issue.

@hizkifw hizkifw merged commit f1b7111 into HoloArchivists:main Jan 8, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants