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

Can I work with frames or merge fragments before play? #6397

Open
Kosmostars7403 opened this issue May 6, 2024 · 3 comments
Open

Can I work with frames or merge fragments before play? #6397

Kosmostars7403 opened this issue May 6, 2024 · 3 comments

Comments

@Kosmostars7403
Copy link

What do you want to do with Hls.js?

Hi, thanks for the work you've done with the player!
My situation: I have a HLS stream with short fragments of a second each. There can be a slight delay between them. This causes the picture to be interrupted and not play correctly. Also there are no timestamps. Can I manually accumulate information or sew fragments and only then playback?

How this situation was solved in C++ with the same thread:
We have a buffer made for 10 frames and we playback from it.
In parallel, we calculate the broadcast fps, which determines the speed of reading from the buffer, so that it does not empty.

Is it possible to do something like this on the frontend? Accumulate *.ts fragments or something else?

Thanks!

What have you tried so far?

No response

@Kosmostars7403 Kosmostars7403 added Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. Question labels May 6, 2024
@robwalch
Copy link
Collaborator

robwalch commented May 6, 2024

You'd need to rewrite the remuxer significantly to do this (and probably demuxer as well as it expects contiguous segments when not marked otherwise) as it sounds like you're not serving valid HLS. Have you considered putting DISCONTINUITY and/or GAP tags between segments in your HLS playlist to accurately describe the program?

@Kosmostars7403
Copy link
Author

Unfortunately, I can't change hls stream on server, have to change playback on frontend. Can I
achieve "DISCONTINUITY and/or GAP tags" behavior with custom loader? Or maybe I can merge fragments in loader and then play it? It doesn't matter if there will be latency for 1-2 seconds btw. Appreciate any help!

@robwalch
Copy link
Collaborator

robwalch commented May 7, 2024

GAP tags prevent a segment from loading. HLS.js will look for an alternative segment in another variant/rendition without a gap or seek over it if none are found. You probably don't want either. Fragments to ignore have a gap property whose value is true.

DISCONTINUITY tags between segments (EXTINF) are essential when timestamps are not contiguous. The discontinuity sequence number for a segment is expresses as Fragment.cc in HLS.js. In theory, you could modify the cc values in LevelDetails.fragments on LEVEL_UPDATE to add discontinuities.

@robwalch robwalch added Stream Issue and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants