html5 - MediaSource through socket stops -




i'm trying stream rtsp live stream through socket.io using ffmpeg (this works fine), need video socket , play on html5 video tag.

to i'm using mediasurce, getting small pieces of video through socket , appending mediasource

this solution reproduces video few seconds o minutes , stops , doesn't throw me error on chrome console

    var socket = io();      var ms = new mediasource();     var sourcebuffer;     var queue = [];     var video = document.getelementbyid("video");     video.src = window.url.createobjecturl(ms);      socket.on('start', function (response) {         console.log(response);         socket.emit('streaming', $stateparams.id);         ms.addeventlistener('sourceopen', videoload, false);         ms.addeventlistener('sourceclose', videoclosed, false);     });       function videoload() {         sourcebuffer = ms.addsourcebuffer('video/webm; codecs="vorbis,vp8"');         sourcebuffer.addeventlistener('update', function () {             if (queue.length > 0 && !sourcebuffer.updating) {                 console.log(queue.length);                 sourcebuffer.appendbuffer(queue.shift());             }         });          socket.on('data', function (response) {             var bytes = new uint8array(response);             var blob = new blob(bytes);             console.log(blob.size);             if (sourcebuffer.updating || queue.length > 0) {                 queue.push(bytes);             } else {                 sourcebuffer.appendbuffer(bytes);             }         });     }      function videoclosed(e) {         console.log('mediasource readystate: ' + this.readystate);     } 

on chrome://media-internals/ video players log show me couple of time this, , video stops

video_buffering_state   buffering_have_enough 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -