kyriesent / node-rtsp-stream

Stream any RTSP stream and output to websocket for consumption by jsmpeg (https://github.com/phoboslab/jsmpeg). HTML5 streaming video! Requires ffmpeg.
MIT License
451 stars 166 forks source link

Dynamically starting and stopping the server #55

Closed mmeyers-solartech closed 4 years ago

mmeyers-solartech commented 4 years ago

Is there a way for a client (I'm currently a JsmpegPlayer in react) to dynamically start and stop the server? Essentially I only want the node.js server to run when a client tries to play it, if nobody is trying to play it I want it to turn off. It looks like out of the box there's some handling to kill the stream and it can handle a loss of connection the actual RTSP server, but I was wondering if the websocket on the other side can kill/start the node server depending on some action.

mmeyers-solartech commented 4 years ago

Closing this one: in videoStream.js the call to this.startMpeg1Stream() can be moved out of the constructor and into the onSocketConnect event.