admin管理员组

文章数量:1406943

I am new to node.js and was debugging a code written by another developer. We have a an IP camera which provides rtsp feed which is being displayed on a webpage. I can view the camera feed using the rtsp url in VLC but the web viewer of camera feed usually gives white screen although it somehow works intermittently.

I was told that it used to work properly when the machine was on Ubuntu 20.04 now it has been updated to Ubuntu 24.

Index.js

const Stream = require("node-rtsp-stream-jsmpeg");
const fs = require("fs");
const https = require("https");

const httpsServer = https.createServer({
  key: fs.readFileSync("./cert/ssl.key"),
  cert: fs.readFileSync("./cert/ssl.crt"),
});


const options = {
    name: "streamName",
    url: "rtsp://10.20.xxx.xx/profile1",
    wsPort: 3333,
    httpsServer: httpsServer
};

let stream = new Stream(options);
stream.start();

index.html

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>DEMO node-rtsp-stream-jsmpeg</title>
  <script src=".min.js"></script>
</head>
<body>
  <div>
    <canvas id="video-canvas">
    </canvas>
  </div>

  <script type="text/javascript">
  var url = "ws://localhost:3333";
  var canvas = document.getElementById('video-canvas');
  var player = new JSMpeg.Player(url, {canvas: canvas});
  </script>
</body>

I tried reinstalling the node modules but it didn't make any difference. I am sure that there is no hardware issue as rtsp connection always works in VLC.

Following is the console log when it fails Following is the console log when it works

本文标签: nodejsrtsp feed fails intermittently using node jsStack Overflow