[英]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.