w3c / media-source

Media Source Extensions
https://w3c.github.io/media-source/
Other
268 stars 58 forks source link

Clarification of sourceBuffer.remove behaviour #223

Closed chrisui closed 4 years ago

chrisui commented 5 years ago

Hey,

I have documented an issue I am having with SourceBuffer.remove() behavior on StackOverflow here whereby my whole TimeRange is removed rather than the designated start/end portion. I'm sorry to bump it here but it seems like those working on the spec would be best to answer and the MSE tag does not seem to get a huge amount of views. This may also end up being something that can be expanded upon and clarified in the spec as well as supporting documentation.

Thanks in advance for any help and answers provided! Sorry if this is documented/answered somewhere already - I've really struggled to work this one out.

Copy of the stackoverflow question:

I have a SourceBuffer with a single entry in .buffered. I have a realtime stream of raw h.264 data arriving which I encode into mp4 and push into the SourceBuffer with .appendBuffer(data). Since this is a realtime stream of data I need to keep clearing the buffer however this is where I encounter my problem. (Ie. I encounter a QuotaExceededError)

For examples sake my single entry in SourceBuffer.buffered has a timerange of 0-10 seconds. My attempt to tidy the buffer is to call SourceBuffer.remove(0, 8). My expectation is that my buffer would be cleared and I'd be left with a timerange of 8-10. However the entire timerange (my only range) is removed and from this point all further appendBuffer calls seem to do nothing.

Three questions relevant to this issue:

  1. How do I a) stop .remove from having this behaviour or b) force new time-ranges in my buffer so that only "old" ranges are removed.
  2. Why do the later appendBuffer calls do nothing? I would expect them to re-populate the SourceBuffer.
  3. Is there a better "MSE" way to handle a realtime stream where I never care about going back in time? Ie. All rendered data can be thrown away.

In case there's some weird Browser/Platform issue going on I'm using Chrome on Ubuntu.

Also, I am basing my code off of https://github.com/xevokk/h264-converter.

jyavenard commented 5 years ago

Everything is fully defined in the spec, read the coded frame removal section. http://w3c.github.io/media-source/#sourcebuffer-coded-frame-remova

I don't believe that section requires any need for clarification.

You do need to know the basics about video codecs and how they work, like the concept of keyframes and P-frame with h264

mwatson2 commented 4 years ago

I propose to close this based on @jyavenard's response above.

wolenetz commented 4 years ago

I agree.