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

Support delayed create of SourceBuffer #6294

Open
fightZy opened this issue Mar 19, 2024 · 4 comments
Open

Support delayed create of SourceBuffer #6294

fightZy opened this issue Mar 19, 2024 · 4 comments

Comments

@fightZy
Copy link

fightZy commented Mar 19, 2024

Is your feature request related to a problem? Please describe.

I have an M3U8 playlist with only audio data for the first few seconds, and then both audio and video data are available. At this point, hls.js will report an error because the video sourceBuffer cannot be found. By checking the hls.js code, I learned that the sourceBuffer seems to only be created during initialization based on the track type owned by the first ts file;

image

image

Describe the solution you'd like

Can you support changing existing sourceBuffers based on actual changes in track types? At least for me, I need to adapt to the addition of track types

Additional context

testUrl: https://cos-public.seewo.com/seewo-ms/uwiykxkvhkkjnhoyhmhoowxxlnphihhh.m3u8

@fightZy fightZy added Feature proposal Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Mar 19, 2024
@robwalch
Copy link
Collaborator

robwalch commented Mar 20, 2024

Mixed track configurations like this are not supported as MSE based playback requires all tracks be buffered before the media element will play though the SourceBuffers.

Still, you can detach and attach the media element or call recoverMediaError to reset the MediaSource when playback reaches the point where the second track becomes available (or is no longer available). It will be a very noticeable operation - the media element is emptied completely before setting back up in roughly a tenth to a half of a second.

Try fixing the issue in your HLS playlist so that each segment includes audio and video. Adding a GAP tag to the segment(s) with only audio will cause them to be skipped allowing for correct setup.

@robwalch robwalch added Not Supported and removed Feature proposal Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Mar 20, 2024
@fightZy
Copy link
Author

fightZy commented Mar 20, 2024

Mixed track configurations like this are not supported as MSE based playback requires all tracks be buffered before the media element will play though the SourceBuffers.

Still, you can detach and attach the media element or call recoverMediaError to reset the MediaSource when playback reaches the point where the second track becomes available (or is no longer available). It will be a very noticeable operation - the media element is emptied completely before setting back up in roughly a tenth to a half of a second.

You really should address the issue in your HLS playlist so that each segment includes audio and video. Adding a GAP tag to the segment(s) with only audio will cause them to be skipped allowing for correct setup.

I have tried it, but it doesn't work because creating a sourceBuffer type is still determined from the first shard file
image

@robwalch
Copy link
Collaborator

I have tried it, but it doesn't work because creating a sourceBuffer type is still determined from the first shard file

That's because you need to playback to start on a segment with both tracks (when playback reaches the point where the second track becomes available). You can achieve this by seeking or setting startPosition.

@fightZy
Copy link
Author

fightZy commented Mar 22, 2024

I have tried it, but it doesn't work because creating a sourceBuffer type is still determined from the first shard file

That's because you need to playback to start on a segment with both tracks (when playback reaches the point where the second track becomes available). You can achieve this by seeking or setting startPosition.

Okay, this can indeed be played normally from where there is video data, but segments with only audio data at the beginning cannot be played🤔

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