NodeJS RTSP流使用节点js?

bprjcwpo  于 2022-12-22  发布在  Node.js
关注(0)|答案(1)|浏览(162)

我正在使用node-rtsp-stream包来运行rtsp流,我如何在mvc结构中实现和回调它//Controller

var RTSP = require('./models/rtsp.js');
var startRTSP = function startRTSP(queryData) {
  console.log("startRTSP enterred******************")
  console.log("queryData : "+JSON.stringify(queryData))
  stream = new Stream({
    name: 'name',
    streamUrl: 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov',
    wsPort: 9999
  });
};

//型号

router.get('/', function(req,res){
       RTSP.startRTSP(req.body);
       res.send("SUCCESS")
})

//查看次数

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

cuxqih211#

安装ffmpeg全局在你的系统第一.
并导入ffmpeg npm包let ffmpeg = require('ffmpeg');
现在尝试流式传输

stream = new Stream({
      name: "name",
      streamUrl: url, // rtsp url
      wsPort: port,  // ws port
      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
      }
    })

相关问题