Answer the question
In order to leave comments, you need to log in
How to start playing a streaming video not from its beginning?
The idea is this:
I'm capturing video and audio using navigator.getUserMedia.
I start recording using MediaRecorder where, at some intervals, I receive a chunk of data in the Uint8Array format, which I send to the server.
Other clients connect to the server and start receiving these chunks and playing them back with code like this:
connection.on("chunk", chunk => {
Chunks.push(chunk);
Video.src = window.URL.createObjectURL(new Blob(Chunks, mimeType));
Video.play();
}
And thus they begin to see in real time what the “streamer” is filming on the camera.But
there are 2 significant problems that essentially come from the same reason.
1. Upon receipt of each new chunk'a from the server, playback starts all over again, which is actually logical because the code is written that way. The fact is that I cannot dynamically add a chunk to the end of the current video so that playback does not update. If you want to advise MediaSource here, then please do not be too lazy to give your own working example of its use with Uint8Array chunks, for example, on JSfiddle, because I already raped my brain with this class ... it never worked for me. Therefore, those examples that you will find in Google, I have probably already seen and tried.
2. You need to be able to start a stream from any chunk. For example, the stream has been going on for 2 hours and there are already 100500 chunks on the server. When connecting a new viewer, he needs to give only all new chunks and not force him to download all the previous ones. In my current situation, everything needs to be downloaded and everything works until the integrity of the stream is violated. If I remove any one chunk from the array - after converting this very array into a Blob - the video will no longer start in the HTML element called video.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question