简体   繁体   中英

Proper way to stop a stream in node-rtsp-stream

I have a nodejs server running and when I make an api request I want to start a new stream and close/stop the old one. The code for starting a new stream:

  Stream = require('node-rtsp-stream');

  this.stream = new Stream({
    name: 'camera-stream',
    streamUrl: 'rtsp://' + camera.cameraUserName + ':' + camera.cameraPassword 
    + '@' + camera.cameraIp,
    wsPort: 9999
  });

Who can i close/stop the current stream?

I tried this code:

this.stream.mpeg1Muxer.stream.kill();
this.stream.streamUrl = 'rtsp://' + camera.cameraUserName + ':' + 
camera.cameraPassword + '@' + camera.cameraIP + ':554';
this.stream.startMpeg1Stream();

I'm not sure that this is the right way to do that.

查看源代码,您会发现VideoStream.prototype.stop = function(){....},因此请尝试-> this.stream.stop();。

node-rtsp-stream has been updated to node-rtsp-stream-es6. In the latter, there is a function .stop() that you can call to stop the streaming.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM