w3c / media-source

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

How to seek outside of buffer? #225

Closed sheddup closed 5 years ago

sheddup commented 5 years ago

Hi, I'm desperately looking for a working example of seeking outside of whats already buffered. I can't for the life of me find a working example on the internet and I've been googling for a long time about this issue.

Here is my attempt https://sheddup.github.io/ This example appends the Init segment (bytes 0-1104898) then waits for the user to click the seek button then fetches a segment starting @ 25s (bytes 2209798-3314696) then sets video.currentTime to 25s Code here -> https://github.com/sheddup/sheddup.github.io/blob/master/bbb.js

When I run https://sheddup.github.io/ Firefox throws Media resource blob:https://sheddup.github.io/c9ca74cb-b020-4e80-ace2-f91e5915f51d could not be decoded. in Chrome I get the error CHUNK_DEMUXER_ERROR_APPEND_FAILED as well as other errors.
I've read the example code @ https://w3c.github.io/media-source/#examples but the seeking portion of this example is vague and incomplete at least that's my ignorant perception.

estobbart commented 5 years ago

The ranges are off, the init segment is only 1907 bytes. You can see after the first GetSegment that there is media already buffered.. video.buffered.end(0). Then the other range 2209798-3314696 doesn't look right either, it starts somewhere in the middle of an mdat box. Take a look at https://www.w3.org/TR/mse-byte-stream-format-isobmff/ and request ranges of the boxes according that spec for init segments and media segments.

sheddup commented 5 years ago

Thanks for the feedback, I merged the changes but still seeking does not work (now I rolled changes back)
You say the ranges are wrong, I'm not disputing that but I can append all segments and play it back fine its just the seeking that's my problem or will having the correct byte ranges help me seek?

estobbart commented 5 years ago

https://github.com/sheddup/sheddup.github.io/pull/2

I generated new content for you, documented the byte range of the content, and added a print to the HTMLMediaElement buffered ranges.