Home > Net >  How to stream two videos concurrently using js or react or node js?
How to stream two videos concurrently using js or react or node js?

Time:11-15

I am trying to create a video streaming website which can play multiple videos concurrently (something similar to a video management system). The requirement for now is just to be able to play two videos at the same time.

All the tutorials I have seen so far are streaming only one video. I am a bit lost and helpless since I am still learning about JS as well. So, here, I am hoping that any of you could make some suggestion on the libraries that I could use (I learned about ffmpeg), even the process on how to make it work or how to kick start.

Any help would be very much appreciated!

I can already stream a video using node JS and I am hoping to play two videos at the same time.

CodePudding user response:

The way video streaming typically works is that the client requests chunks of the video at a time using an http request (with the Range header) and the server sends each chunk of the video as requested. The client then uses it's own logic to decide when it needs to request the next chunk.

So, for a server to support multiple clients streaming video, all it has to do is be able to respond to multiple http requests in a timely manner and have enough server bandwidth for the data being sent to the clients.

Pretty much any basic web server with enough bandwidth to the internet should be able to stream two videos. And, this should work just fine with nodejs and the http server that it has built-in. You will, of course, have to write your own request handlers that support the Range header appropriately so that your server can inform the clients that you support the Range header and so that you can properly fulfill the client requests when they request a particular byte range of the video.

As for ffmpeg, that's more typically used for converting videos to different formats. Ideally, your server would store the videos in a format that is already ready for streaming and you would not need to use ffmpeg in the actual streaming process.

  • Related