0

In my backend code (below) I am streaming rtsp and I want to send it to my frontend code. Specifically, I want the streaming response data to be sent to my html page and rendered as a video in a canvas tag. Is this possible?

Stream = require('node-rtsp-stream');
router.post('/',function(req,res){
  stream = new Stream({
    name: 'name',
     streamUrl:'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov',
     wsPort: 9999
  });
    res.send(stream);
});

Frontend code is below:

$.ajax({
        url:'/test',
        type:'POST',
        cache:false,
        success:function(data){
            console.log("RTSP Result  : "+JSON.stringify(data))
              var canvas = document.getElementById("videostream");
              var ws = new WebSocket("ws://localhost:9999")
              var player = new jsmpeg(ws, {canvas:canvas, 
                           autoplay:true,audio:false,loop: true});
        }
    });
Shree
  • 145
  • 4
  • 15

1 Answers1

0

With node-rtsp-stream you have all you need to connect to rtsp and to pipe the stream through a websocket connection. All you have to do is at the browser side to use the module jsmpeg to display the stream in a canvas html element. I have done this with angular. Make sure that you have installed ffmpeg and the node process find it (PATH).