-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple video streams, different websocket? #391
Comments
Can anybody please respond to the above question? I need to implement something similar. I have multiple cameras on the user dashboard and the source will be RTSP streams. How to manage this using web sockets solution? |
I accomplish this using different ports. I am not sure if it can be done using the same port with different identifiers. node websocket-relay.js streamid1 8091 8081 ffmpeg ... http://localhost:8091/streamid1 Is that acceptable or do you need to only use a single port for every stream? |
Basically, I will not be knowing how many streams will be there. There might be chances of having 50-100 jsmpeg streams at the same time. So how will manage the ports and start the listening process for different ports at the run time? |
My project is now working as intended. I endeded up opening 16 different websocket relays. This is done on boot using systemd daemon script:
It calls bash script:
So all the websockets are opened in background using screen. FFmpeg sends stream to port 100XX and I watch it in html GUI on port 110XX. 16 in total. And I do round robin stream rotation on each of those 16 sockets. FFmpeg starts new stream and after X seconds I kill previous one for smooth transition. The software that fires the FFmpeg processes is custom written in .NET and running under mono framework. Here a warning if you will use multiple FFmpeg instances. Each instance uses 48 threads no matter what -thread parameter I use. So if I have max 32 ffmpeg instances. Plus 4 threads to monitor ffmpeg output. 32 * 48+32 * 4 = 1664 opened threads. Linux could have a limit how many threads per user can be opened. GUI looks fantastic and very low system resources are needed to watch all 16 streams using jsmpeg library: Using OBS and its browser source I can grab this web page and stream it forward as video (multicast, HLS, http, ...). This is stable and I have no problem with opening 16 sockets in background- |
Thanks for your description. I think I have to do the same workaround. But I've a fear that if there is a situation of x+1 streams at a time, how we will manage the new port? In your case x is 16. |
Please note that the That said, spawning multiple nodejs processes has one advantage: nodejs is inherently single threaded. So if you want to serve hundreds of different streams and/or thousands of clients with the same script, you may need to investigate nodejs cluster to fully utilize your server. |
With the same ports and reading through streamId, I got this. https://watch.screencastify.com/v/ujGncbWp6GwVdFM8FuK1 |
jsmpeg DOES provide fatest video display performance. |
Hello,
I would like to use the websocket relay. I have it running and I can push the video from ffmpeg to it with "secret" key. I wish to push multiple streams via multiple ffmpeg commands. Something like:
ffmpeg ... http://localhost:8081/secret/streamid1
ffmpeg ... http://localhost:8081/secret/streamid2
ffmpeg ... http://localhost:8081/secret/streamid3
And then fetch each over websocket url:
http://localhost:8082/streamid1
http://localhost:8082/streamid2
http://localhost:8082/streamid3
Can this be done or I need a different solution?
Thank you,
The text was updated successfully, but these errors were encountered: