简体   繁体   English

在node-rtsp-stream中停止流的正确方法

[英]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. 我有一个运行中的nodejs服务器,当我发出api请求时,我想启动一个新流并关闭/停止旧流。 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. node-rtsp-stream已更新为node-rtsp-stream-es6。 In the latter, there is a function .stop() that you can call to stop the streaming. 在后者中,有一个.stop()函数,您可以调用该函数来停止流传输。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NextJS 不适用于 jsmpeg/node-rtsp-stream。 试图显示 RTSP stream - NextJS not working with jsmpeg/node-rtsp-stream. Trying to display RTSP stream 如何录制 RTSP 流 - How to recorder a RTSP Stream 在 node.js 变换 stream 中处理背压的正确方法是什么? - What's the proper way to handle back-pressure in a node.js Transform stream? 如何使用 nodejs 服务器流式传输 RTSP? - How to stream RTSP with a nodejs server? 将 rtsp ip 摄像头流式传输到网站 - Stream rtsp ip camera to website 有一些方法可以用Node JS传输照片吗? - There is some way to stream a photo with Node JS? 有没有办法将Node流作为可迭代的? - Is there any way to work with a Node stream as an iterable? 将RTSP从带有节点媒体服务器的IP凸轮重新流式传输到http / ws并使用html显示 - Re-stream RTSP from IP cam with Node Media Server to http/ws and display it with html 如何设置接受 RTMP 和/或 RTSP 流并使用 WebRTC 到 stream 到客户端(浏览器)的直播 Node js 服务器? - How to setup a livestream Node js server that accepts RTMP and/or RTSP streams and use WebRTC to stream to clients (browsers)? 从解码音频流(移动)清理内存的正确方法 - Proper way to clean up memory from decoded audio stream (mobile)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM