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

add auto restart #27

Closed dandanXO closed 4 years ago

dandanXO commented 5 years ago

On server:


class streams {
    constructor() {
        this.stream

    }
    starStream() {
        this.stream = new Stream({
            name: 'cameraStream',
            streamUrl: 'rtsp://192.168.2.236/user=admin&password=&channel=1&stream=0.sdp',
            wsPort: 9999,
            reconnect: true,
            ffmpegOptions: { 
                '-reconnect' :1,
                '-reconnect_at_eof':1,
                '-reconnect_streamed' : 1
            }
        });
    }
    restartStream(){
        console.log('restart stream')
        this.stream.restart()
    }

}
module.exports = streams; // stream;

if network down or something error it will be auto connect and start

kyriesent commented 5 years ago

@dandanXO thanks for the help! Sorry for the delay, my workplace has been moving and we have had a busy season.

The project is currently written in coffeescript, so the changes that you made will likely be wiped out when the javascript is compiled. This is a good idea though, and I think it's worth exploring having a restart option.

kyriesent commented 4 years ago

Closing for now. Thanks again @dandanXO