简体   繁体   English

如何使用 nodejs 服务器流式传输 RTSP?

[英]How to stream RTSP with a nodejs server?

Hello I'm working on a new project and I want to stream through a node web server a RTSP stream from my Network Camera.您好,我正在开展一个新项目,我想通过节点 Web 服务器流式传输来自网络摄像机的 RTSP 流。 I don't want to steam using the ONFIV protocol but straight away the rtsp stream.我不想使用 ONFIV 协议,而是直接使用 rtsp 流。 So far I have tested the most of the projects that presented at github but I had no success.到目前为止,我已经测试了 github 上展示的大部分项目,但没有成功。 Does anyone now a documentation or a project that explain (server and html side) how to stream RTSP stream using a node javascript server to a HTML page?现在有没有人解释(服务器端和 html 端)如何使用节点 javascript 服务器将 RTSP 流流式传输到 HTML 页面的文档或项目?

Use node-rtsp-stream node module, install ffmpeg, set ffmpeg PATH OS wide. 使用node-rtsp-stream节点模块,安装ffmpeg,设置ffmpeg PATH OS范围。 At the browser level use node module jsmpeg and display stream within a canvas element. 在浏览器级别使用节点模块jsmpeg并在canvas元素中显示流。

Server.js:服务器.js:

  var stream = require('node-rtsp-stream')
  const express = require('express')
  const app = express()

  stream = new stream({
    name: 'name',
    streamUrl: 'rtsp://192.168.0.111:8080/h264_ulaw.sdp',
    wsPort: 9999
})  

client.html:客户端.html:

  <html>
  <body>enter code here
    <div style="height: 30rem; width:30rem ;">
        <canvas id="canvas" onclick="stop()"></canvas>
    </div>

  </body>

  <script type="text/javascript" src="jsmpeg.min.js"></script>
  <script type="text/javascript">
    player = new JSMpeg.Player('ws://localhost:9999', {
      canvas: document.getElementById('canvas') // Canvas should be a canvas DOM 
 element
    })  
    function stop(){
        player.stop()
    }
 </script>
  </html>

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

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