Linked Questions

Popular Questions

how to make node js online video streaming

Asked by At

here is my node js code

socket.on('stream',()=>{
        let  readStream = fs.createReadStream(__dirname+'/video.mp4');
        readStream.on('data',(chunk)=>{

           socket.emit('stream-chunk',chunk);
            //res.render("hello");
        });
    });

and here is the client side

            let chunkArray = [];
            socket.on('stream-chunk', (chunk) => { 
                    chunkArray.push(chunk);
                    //console.log(chunk);
                    //var url = URL.createObjectURL(chunk);
                    //alert(url);
                    $("#video").attr("src",url);

            });

so as you can see I just want to get a video file from node server and stream it using buffers.. so far the chunks come as ArrayBuffers to client side. But I have no idea how to make use this incoming chunks to my html5 <video> element

here is my client side html tag

<video controls type="video/mp4" src="" id="video" width="300" height="300"></video>

Related Questions