SourceBuffer.remove(start, end) removes whole buffered TimeRange (How to handle realtime stream with MSE?)
up vote
1
down vote
favorite
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:
- 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.
- Why do the later
appendBuffer
calls do nothing? I would expect them to re-populate theSourceBuffer
. - 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.
javascript video-streaming html5-video media-source
add a comment |
up vote
1
down vote
favorite
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:
- 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.
- Why do the later
appendBuffer
calls do nothing? I would expect them to re-populate theSourceBuffer
. - 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.
javascript video-streaming html5-video media-source
"Since this is a realtime stream of data I need to keep clearing the buffer" It's been some years since I've messed with this, but I don't remember ever having to clear past buffer with realtime streams. I just kept appending more, and let the browser evict old data. I could be wrong about this though. Did you have an issue where memory was continuously being consumed?
– Brad
Nov 18 at 3:18
Yes, in chrome i get aQuotaExceededError
at around 150mb. Details here: developers.google.com/web/updates/2017/10/quotaexceedederror
– Chris Pearce
Nov 18 at 15:55
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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:
- 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.
- Why do the later
appendBuffer
calls do nothing? I would expect them to re-populate theSourceBuffer
. - 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.
javascript video-streaming html5-video media-source
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:
- 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.
- Why do the later
appendBuffer
calls do nothing? I would expect them to re-populate theSourceBuffer
. - 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.
javascript video-streaming html5-video media-source
javascript video-streaming html5-video media-source
edited Nov 18 at 16:17
asked Nov 14 at 22:47
Chris Pearce
4511617
4511617
"Since this is a realtime stream of data I need to keep clearing the buffer" It's been some years since I've messed with this, but I don't remember ever having to clear past buffer with realtime streams. I just kept appending more, and let the browser evict old data. I could be wrong about this though. Did you have an issue where memory was continuously being consumed?
– Brad
Nov 18 at 3:18
Yes, in chrome i get aQuotaExceededError
at around 150mb. Details here: developers.google.com/web/updates/2017/10/quotaexceedederror
– Chris Pearce
Nov 18 at 15:55
add a comment |
"Since this is a realtime stream of data I need to keep clearing the buffer" It's been some years since I've messed with this, but I don't remember ever having to clear past buffer with realtime streams. I just kept appending more, and let the browser evict old data. I could be wrong about this though. Did you have an issue where memory was continuously being consumed?
– Brad
Nov 18 at 3:18
Yes, in chrome i get aQuotaExceededError
at around 150mb. Details here: developers.google.com/web/updates/2017/10/quotaexceedederror
– Chris Pearce
Nov 18 at 15:55
"Since this is a realtime stream of data I need to keep clearing the buffer" It's been some years since I've messed with this, but I don't remember ever having to clear past buffer with realtime streams. I just kept appending more, and let the browser evict old data. I could be wrong about this though. Did you have an issue where memory was continuously being consumed?
– Brad
Nov 18 at 3:18
"Since this is a realtime stream of data I need to keep clearing the buffer" It's been some years since I've messed with this, but I don't remember ever having to clear past buffer with realtime streams. I just kept appending more, and let the browser evict old data. I could be wrong about this though. Did you have an issue where memory was continuously being consumed?
– Brad
Nov 18 at 3:18
Yes, in chrome i get a
QuotaExceededError
at around 150mb. Details here: developers.google.com/web/updates/2017/10/quotaexceedederror– Chris Pearce
Nov 18 at 15:55
Yes, in chrome i get a
QuotaExceededError
at around 150mb. Details here: developers.google.com/web/updates/2017/10/quotaexceedederror– Chris Pearce
Nov 18 at 15:55
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
It's all in the MSE spec.
http://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal
Step 3.3: Remove all media data, from this track buffer, that contain starting timestamps greater than or equal to start and less than the remove end timestamp.
So the user agent will remove all the data you've requested, from 0 to 8s
Then
Step 3.4: Remove all possible decoding dependencies on the coded frames removed in the previous step by removing all coded frames from this track buffer between those frames removed in the previous step and the next random access point after those removed frames.
The user agent will remove all frames that depend on the ones you've just removed. Due to the way h264 works (and all modern video codec) that is all frames following the last keyframe until the next keyframe, as none of those frames can now be decoded.
There is no keyframe in range 8 to 10s, so they are all removed
Why do the later appendBuffer calls do nothing? I would expect them to
re-populate the SourceBuffer.
You have removed data, as per spec, the next frame you add must be a keyframe. If the segment you add contains no keyframe, nothing will be added.
If the data you add is made of a single keyframe at the start followed by just P-frame, then you can't remove any frames in the middle without rendering unusable all the ones that follow
Ah, this makes a lot of sense. Would a reasonable solution be to have more keyframes (I'm presuming in the data I'm currently simply has the one keyframe at the beginning created)?
– Chris Pearce
Nov 18 at 20:08
MSE requires regular keyframes, otherwise you would never be able to delete any frames ever, including once your source buffer is full and you want to evict data. There is a ongoing discussion on how we could make such content usable by MSE: that would require disabling seeking in particular.
– jyavenard
Nov 18 at 20:10
I've just tested the default behaviour (no manual buffer removal - just keep appending) in Firefox and it works fine. The buffer appears to get automatically rotated to avoid the QuotaExceededError? This seems to have be an expected behavior of Chrome as well but has before been a problem with high bandwidth (we're doing about 6MB/s). This bug looks very familiar but was supposedly addressed in 2016. bugs.chromium.org/p/chromium/issues/detail?id=563292
– Chris Pearce
Nov 18 at 20:15
If your content is made of a single keyframe at the start and none after, you will his QuotaExceededError. It's just a matter of time. The sourcebuffer maximum size is 100MiB in Firefox and 150MiB in Chrome
– jyavenard
Nov 19 at 14:01
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
It's all in the MSE spec.
http://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal
Step 3.3: Remove all media data, from this track buffer, that contain starting timestamps greater than or equal to start and less than the remove end timestamp.
So the user agent will remove all the data you've requested, from 0 to 8s
Then
Step 3.4: Remove all possible decoding dependencies on the coded frames removed in the previous step by removing all coded frames from this track buffer between those frames removed in the previous step and the next random access point after those removed frames.
The user agent will remove all frames that depend on the ones you've just removed. Due to the way h264 works (and all modern video codec) that is all frames following the last keyframe until the next keyframe, as none of those frames can now be decoded.
There is no keyframe in range 8 to 10s, so they are all removed
Why do the later appendBuffer calls do nothing? I would expect them to
re-populate the SourceBuffer.
You have removed data, as per spec, the next frame you add must be a keyframe. If the segment you add contains no keyframe, nothing will be added.
If the data you add is made of a single keyframe at the start followed by just P-frame, then you can't remove any frames in the middle without rendering unusable all the ones that follow
Ah, this makes a lot of sense. Would a reasonable solution be to have more keyframes (I'm presuming in the data I'm currently simply has the one keyframe at the beginning created)?
– Chris Pearce
Nov 18 at 20:08
MSE requires regular keyframes, otherwise you would never be able to delete any frames ever, including once your source buffer is full and you want to evict data. There is a ongoing discussion on how we could make such content usable by MSE: that would require disabling seeking in particular.
– jyavenard
Nov 18 at 20:10
I've just tested the default behaviour (no manual buffer removal - just keep appending) in Firefox and it works fine. The buffer appears to get automatically rotated to avoid the QuotaExceededError? This seems to have be an expected behavior of Chrome as well but has before been a problem with high bandwidth (we're doing about 6MB/s). This bug looks very familiar but was supposedly addressed in 2016. bugs.chromium.org/p/chromium/issues/detail?id=563292
– Chris Pearce
Nov 18 at 20:15
If your content is made of a single keyframe at the start and none after, you will his QuotaExceededError. It's just a matter of time. The sourcebuffer maximum size is 100MiB in Firefox and 150MiB in Chrome
– jyavenard
Nov 19 at 14:01
add a comment |
up vote
0
down vote
It's all in the MSE spec.
http://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal
Step 3.3: Remove all media data, from this track buffer, that contain starting timestamps greater than or equal to start and less than the remove end timestamp.
So the user agent will remove all the data you've requested, from 0 to 8s
Then
Step 3.4: Remove all possible decoding dependencies on the coded frames removed in the previous step by removing all coded frames from this track buffer between those frames removed in the previous step and the next random access point after those removed frames.
The user agent will remove all frames that depend on the ones you've just removed. Due to the way h264 works (and all modern video codec) that is all frames following the last keyframe until the next keyframe, as none of those frames can now be decoded.
There is no keyframe in range 8 to 10s, so they are all removed
Why do the later appendBuffer calls do nothing? I would expect them to
re-populate the SourceBuffer.
You have removed data, as per spec, the next frame you add must be a keyframe. If the segment you add contains no keyframe, nothing will be added.
If the data you add is made of a single keyframe at the start followed by just P-frame, then you can't remove any frames in the middle without rendering unusable all the ones that follow
Ah, this makes a lot of sense. Would a reasonable solution be to have more keyframes (I'm presuming in the data I'm currently simply has the one keyframe at the beginning created)?
– Chris Pearce
Nov 18 at 20:08
MSE requires regular keyframes, otherwise you would never be able to delete any frames ever, including once your source buffer is full and you want to evict data. There is a ongoing discussion on how we could make such content usable by MSE: that would require disabling seeking in particular.
– jyavenard
Nov 18 at 20:10
I've just tested the default behaviour (no manual buffer removal - just keep appending) in Firefox and it works fine. The buffer appears to get automatically rotated to avoid the QuotaExceededError? This seems to have be an expected behavior of Chrome as well but has before been a problem with high bandwidth (we're doing about 6MB/s). This bug looks very familiar but was supposedly addressed in 2016. bugs.chromium.org/p/chromium/issues/detail?id=563292
– Chris Pearce
Nov 18 at 20:15
If your content is made of a single keyframe at the start and none after, you will his QuotaExceededError. It's just a matter of time. The sourcebuffer maximum size is 100MiB in Firefox and 150MiB in Chrome
– jyavenard
Nov 19 at 14:01
add a comment |
up vote
0
down vote
up vote
0
down vote
It's all in the MSE spec.
http://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal
Step 3.3: Remove all media data, from this track buffer, that contain starting timestamps greater than or equal to start and less than the remove end timestamp.
So the user agent will remove all the data you've requested, from 0 to 8s
Then
Step 3.4: Remove all possible decoding dependencies on the coded frames removed in the previous step by removing all coded frames from this track buffer between those frames removed in the previous step and the next random access point after those removed frames.
The user agent will remove all frames that depend on the ones you've just removed. Due to the way h264 works (and all modern video codec) that is all frames following the last keyframe until the next keyframe, as none of those frames can now be decoded.
There is no keyframe in range 8 to 10s, so they are all removed
Why do the later appendBuffer calls do nothing? I would expect them to
re-populate the SourceBuffer.
You have removed data, as per spec, the next frame you add must be a keyframe. If the segment you add contains no keyframe, nothing will be added.
If the data you add is made of a single keyframe at the start followed by just P-frame, then you can't remove any frames in the middle without rendering unusable all the ones that follow
It's all in the MSE spec.
http://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal
Step 3.3: Remove all media data, from this track buffer, that contain starting timestamps greater than or equal to start and less than the remove end timestamp.
So the user agent will remove all the data you've requested, from 0 to 8s
Then
Step 3.4: Remove all possible decoding dependencies on the coded frames removed in the previous step by removing all coded frames from this track buffer between those frames removed in the previous step and the next random access point after those removed frames.
The user agent will remove all frames that depend on the ones you've just removed. Due to the way h264 works (and all modern video codec) that is all frames following the last keyframe until the next keyframe, as none of those frames can now be decoded.
There is no keyframe in range 8 to 10s, so they are all removed
Why do the later appendBuffer calls do nothing? I would expect them to
re-populate the SourceBuffer.
You have removed data, as per spec, the next frame you add must be a keyframe. If the segment you add contains no keyframe, nothing will be added.
If the data you add is made of a single keyframe at the start followed by just P-frame, then you can't remove any frames in the middle without rendering unusable all the ones that follow
edited Nov 18 at 18:46
answered Nov 18 at 18:36
jyavenard
1,5011732
1,5011732
Ah, this makes a lot of sense. Would a reasonable solution be to have more keyframes (I'm presuming in the data I'm currently simply has the one keyframe at the beginning created)?
– Chris Pearce
Nov 18 at 20:08
MSE requires regular keyframes, otherwise you would never be able to delete any frames ever, including once your source buffer is full and you want to evict data. There is a ongoing discussion on how we could make such content usable by MSE: that would require disabling seeking in particular.
– jyavenard
Nov 18 at 20:10
I've just tested the default behaviour (no manual buffer removal - just keep appending) in Firefox and it works fine. The buffer appears to get automatically rotated to avoid the QuotaExceededError? This seems to have be an expected behavior of Chrome as well but has before been a problem with high bandwidth (we're doing about 6MB/s). This bug looks very familiar but was supposedly addressed in 2016. bugs.chromium.org/p/chromium/issues/detail?id=563292
– Chris Pearce
Nov 18 at 20:15
If your content is made of a single keyframe at the start and none after, you will his QuotaExceededError. It's just a matter of time. The sourcebuffer maximum size is 100MiB in Firefox and 150MiB in Chrome
– jyavenard
Nov 19 at 14:01
add a comment |
Ah, this makes a lot of sense. Would a reasonable solution be to have more keyframes (I'm presuming in the data I'm currently simply has the one keyframe at the beginning created)?
– Chris Pearce
Nov 18 at 20:08
MSE requires regular keyframes, otherwise you would never be able to delete any frames ever, including once your source buffer is full and you want to evict data. There is a ongoing discussion on how we could make such content usable by MSE: that would require disabling seeking in particular.
– jyavenard
Nov 18 at 20:10
I've just tested the default behaviour (no manual buffer removal - just keep appending) in Firefox and it works fine. The buffer appears to get automatically rotated to avoid the QuotaExceededError? This seems to have be an expected behavior of Chrome as well but has before been a problem with high bandwidth (we're doing about 6MB/s). This bug looks very familiar but was supposedly addressed in 2016. bugs.chromium.org/p/chromium/issues/detail?id=563292
– Chris Pearce
Nov 18 at 20:15
If your content is made of a single keyframe at the start and none after, you will his QuotaExceededError. It's just a matter of time. The sourcebuffer maximum size is 100MiB in Firefox and 150MiB in Chrome
– jyavenard
Nov 19 at 14:01
Ah, this makes a lot of sense. Would a reasonable solution be to have more keyframes (I'm presuming in the data I'm currently simply has the one keyframe at the beginning created)?
– Chris Pearce
Nov 18 at 20:08
Ah, this makes a lot of sense. Would a reasonable solution be to have more keyframes (I'm presuming in the data I'm currently simply has the one keyframe at the beginning created)?
– Chris Pearce
Nov 18 at 20:08
MSE requires regular keyframes, otherwise you would never be able to delete any frames ever, including once your source buffer is full and you want to evict data. There is a ongoing discussion on how we could make such content usable by MSE: that would require disabling seeking in particular.
– jyavenard
Nov 18 at 20:10
MSE requires regular keyframes, otherwise you would never be able to delete any frames ever, including once your source buffer is full and you want to evict data. There is a ongoing discussion on how we could make such content usable by MSE: that would require disabling seeking in particular.
– jyavenard
Nov 18 at 20:10
I've just tested the default behaviour (no manual buffer removal - just keep appending) in Firefox and it works fine. The buffer appears to get automatically rotated to avoid the QuotaExceededError? This seems to have be an expected behavior of Chrome as well but has before been a problem with high bandwidth (we're doing about 6MB/s). This bug looks very familiar but was supposedly addressed in 2016. bugs.chromium.org/p/chromium/issues/detail?id=563292
– Chris Pearce
Nov 18 at 20:15
I've just tested the default behaviour (no manual buffer removal - just keep appending) in Firefox and it works fine. The buffer appears to get automatically rotated to avoid the QuotaExceededError? This seems to have be an expected behavior of Chrome as well but has before been a problem with high bandwidth (we're doing about 6MB/s). This bug looks very familiar but was supposedly addressed in 2016. bugs.chromium.org/p/chromium/issues/detail?id=563292
– Chris Pearce
Nov 18 at 20:15
If your content is made of a single keyframe at the start and none after, you will his QuotaExceededError. It's just a matter of time. The sourcebuffer maximum size is 100MiB in Firefox and 150MiB in Chrome
– jyavenard
Nov 19 at 14:01
If your content is made of a single keyframe at the start and none after, you will his QuotaExceededError. It's just a matter of time. The sourcebuffer maximum size is 100MiB in Firefox and 150MiB in Chrome
– jyavenard
Nov 19 at 14:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309874%2fsourcebuffer-removestart-end-removes-whole-buffered-timerange-how-to-handle%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"Since this is a realtime stream of data I need to keep clearing the buffer" It's been some years since I've messed with this, but I don't remember ever having to clear past buffer with realtime streams. I just kept appending more, and let the browser evict old data. I could be wrong about this though. Did you have an issue where memory was continuously being consumed?
– Brad
Nov 18 at 3:18
Yes, in chrome i get a
QuotaExceededError
at around 150mb. Details here: developers.google.com/web/updates/2017/10/quotaexceedederror– Chris Pearce
Nov 18 at 15:55