videojs / mux.js

Lightweight utilities for inspecting and manipulating video container formats.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic usage expample error

B-R-Bender opened this issue · comments

Hi guys, coluld you, please, help me with basic example from readme?

I've copy/paste code to index.html, add .ts file near index.html.
Update segments array with my file name
segments = [ "20sec.ts", ];
try to run it and got an error in console:

DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer is still processing an 'appendBuffer' or 'remove' operation.

also, I see console.log(muxjs.mp4.tools.inspect(data)); 2 times, so I guess this is the reason why SourceBuffer is still processing but why is this happen?

image

what should I do to make this basic example to work? thanks!

Hi, I ran into the same problem and realised removing line 63 forEach loop will make it work.
The forEach loop is not necessary and the requests fetching should be done one after another instead of in one time.

Also, line 60 should add return to prevent the undefined request from being sent.

thanks @luisliuchao I'll give it a try

Why the forEach is necessary for this demo? once a segment is appended to the buffer updateend is called and next one is appended too, so it is not necessary the loop.

Try with this:

if (segments.length == 0) {
    // notify MSE that we have no more segments to append.
    mediaSource.endOfStream();
    return
}

// segments.forEach((segment) => {
    // fetch the next segment from the segments array and pass it into the transmuxer.push method
    fetch(segments.shift()).then((response)=>{
      return response.arrayBuffer();
    }).then((response)=>{
      transmuxer.push(new Uint8Array(response));
      transmuxer.flush();
    })
//   })