Not able to Show live camera RTSP streaming with AngularJS

1k Views Asked by At

I'm developing a web application using angularjs, I need to add a window that shows a live RTSP streaming.I can be done that with JSMpeg js library. In the server side I found this nodejs example

Stream = require('node-rtsp-stream')
stream = new Stream({
   name: 'name',
   streamUrl: 'rtsp_url',
   wsPort: 8081,
   ffmpegOptions: { // options ffmpeg flags
      '-stats': '', // an option with no neccessary value uses a blank string
      '-r': 30 // options with required values specify the value after the key
   }
})

in the browser side first i tried a simple HTML5 :

<html>
<body>
<div>
  <canvas id="canvas"  width="1920" height="1080" style="display: block; width: 40%;"></canvas>
</div>
</body>

<script type="text/javascript" src="jsmpeg.min.js"></script>
<script type="text/javascript">
   //var ws = new WebSocket('ws://localhost:9999');
    player = new JSMpeg.Player('ws://localhost:9999', {
      canvas: document.getElementById('canvas'), autoplay: true, audio: false, loop: true
    })  
</script>

This HTML5 page works fine and I got in my web page a live streaming. After that I tried to adapt this HTML code to angularJS: I added the canvas tag to the corresponding html file:

<canvas id="canvas"  width="502" height="237" style="display: block; width: 40%;"></canvas>

Then I tried controller as follow:

var streamingcanvas = document.getElementById("canvas");
let player = new JSMpeg.Player('ws://localhost:8081', {
    canvas: streamingcanvas, autoplay: true, audio: false, loop: true
})

the result I get is that no streaming in my web page an no errors in the console.

what's missing in my code?

0

There are 0 best solutions below