繁体   English   中英

rtsp流节点js ip相机jsmpeg失败

[英]rtsp streaming node js ip camera jsmpeg fail

接了一个ip摄像头,但问题像图片

运行节点 app.js 时“帧= 1970 fps=2.0 q=7.6 大小= 22457kB 时间=00:16:25.00 比特率= 186.8kbits/s dup=0 drop=3 speed=1.01x”

执行 index.html "name: New WebSocket Connection (1 total)kB time=00:00:43.00 bitrate= 147.0kbits/s speed=1.28x"

但是,有时canvas上没有出现摄像头,打印如下图

应用程序.js

 // const onvif = require('node-onvif'); // console.log('Start the discovery process.'); // // Find the ONVIF network cameras. // // It will take about 3 seconds. // onvif.startProbe().then((device_info_list) => { // console.log(device_info_list.length + ' devices were found.'); // // Show the device name and the URL of the end point. // device_info_list.forEach((info) => { // console.log('- ' + info.urn); // console.log(' - ' + info.name); // console.log(' - ' + info.xaddrs[0]); // }); // }).catch((error) => { // console.error(error); // }); /////////////////////////////////////// // const onvif = require('node-onvif'); // // Create an OnvifDevice object // let device = new onvif.OnvifDevice({ // xaddr: 'http://192.168.88.4:8081/onvif/device_service', // user: 'admin', // pass: 'tmzkdl123$' // }); // // Initialize the OnvifDevice object // device.init().then(() => { // // Get the UDP stream URL // let url = device.getUdpStreamUrl(); // console.log(url); // }).catch((error) => { // console.error(error); // }); ///////////////////////////////////////// Stream = require('node-rtsp-stream') stream = new Stream({ name: 'name', streamUrl: 'rtsp://192.168.88.8:554/0/onvif/profile1/media.smp', wsPort: 9900, 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 } })

索引.html

<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>rtsp</title>

        <div><canvas id="video" width="640" height="360"></canvas></div>
        <script type="text/javascript" src="jsmpeg.js"></script>
        <script type="text/javascript">
            var canvas = document.getElementById('video');
            var ws = new WebSocket("ws://192.168.88.174:9900");
                var player = new jsmpeg(ws, {canvas:canvas, autoplay:true, audio:false, loop:true});
        </script>
    </head>
    <body>
    </body>
</html>

图像 url在此处输入图像描述

我也有这个问题,但解决了,你必须从https://jsmpeg.com/下载 jsmpeg.min.js 并将其替换为 jsmpeg.js 文件然后更改此行

<script type="text/javascript" src="jsmpeg.js"></script>

<script type="text/javascript" src="jsmpeg.min.js"></script>

之后清除这条线

var ws = new WebSocket("ws://192.168.88.174:9900");

并更改此行

var player = new jsmpeg(ws, {canvas:canvas, autoplay:true, audio:false, loop:true});

对此:

var player = new JSMpeg.Player("ws://192.168.88.174:9900", {canvas:canvas, autoplay:true, audio:false, loop:true});

你的问题必须解决!

暂无
暂无

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

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