admin管理员组文章数量:1330602
Goal
My goal is to display my IP cam's RTSP-output stream on a standard HTML-page (html5 + css3 + vanilla javascript, no magic = no plugins). The HTML-page should be hosted in a NGINX web server on my Raspberry Pi.
My equipment
The setup I am using is a Raspberry Pi 3 B+ with Rasbian OS, Node.js and Node-Media-Server package, NGINX (but I do not believe that NGINX is important for my problem? I have not made any config for the Node-Media-Server in it anyway.) An IP-camera, and a browser.
What I have tried
The readme in the Node-Media-Server-project is detailed and there is a tutorial describing almost exactly what I want to do. Specifically, there is a markup example on how the live stream could be accessed:
<html>
<head>
<title>Camera</title>
</head>
<body>
<script src=".js/1.4.0/flv.min.js"></script>
<video id="videoElement"></video>
<script>
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url: 'http://localhost:8000/live/uterum.flv'
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
}
</script>
</body>
</html>
This is how I start the media server on my Raspberry PI, kommandoran-mediaserver.js
:
const { NodeMediaServer } = require('node-media-server');
const config = {
logType: 3, // 3 - Log everything (debug)
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 60,
ping_timeout: 30
},
http: {
port: 8000,
allow_origin: '*'
},
relay: {
ffmpeg: '/usr/local/bin/ffmpeg',
tasks: [
{
app: 'cctv',
mode: 'static',
edge: 'rtsp://<USER>:<PASSWORD>@10.0.0.111/live1.sdp',
name: 'uterum',
rtsp_transport : 'tcp' //['udp', 'tcp', 'udp_multicast', 'http']
}
]
}
};
var nms = new NodeMediaServer(config)
nms.run();
My problem and question
When I try to view camera.html
(see markup above) via the Chromium browser on Raspberry Pi (i.e. local host), nothing is displayed. In the Chromium debug inspector there are no javascript errors, but I get this:
GET http://localhost:8000/live/uterum.flv net::ERR_EMPTY_RESPONSE
Here is a screenshot from the node terminal:
The red area illustrates the output when I try to make a request to http://localhost:8000/live/uterum.flv
.
I suppose I try to reach the wrong endpoint but which is correct? The documentation states http://localhost:8000/live/STREAM_NAME.flv
. What is "STREAM_NAME
" in my case?
Goal
My goal is to display my IP cam's RTSP-output stream on a standard HTML-page (html5 + css3 + vanilla javascript, no magic = no plugins). The HTML-page should be hosted in a NGINX web server on my Raspberry Pi.
My equipment
The setup I am using is a Raspberry Pi 3 B+ with Rasbian OS, Node.js and Node-Media-Server package, NGINX (but I do not believe that NGINX is important for my problem? I have not made any config for the Node-Media-Server in it anyway.) An IP-camera, and a browser.
What I have tried
The readme in the Node-Media-Server-project is detailed and there is a tutorial describing almost exactly what I want to do. Specifically, there is a markup example on how the live stream could be accessed:
<html>
<head>
<title>Camera</title>
</head>
<body>
<script src="https://cdn.bootcss./flv.js/1.4.0/flv.min.js"></script>
<video id="videoElement"></video>
<script>
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url: 'http://localhost:8000/live/uterum.flv'
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
}
</script>
</body>
</html>
This is how I start the media server on my Raspberry PI, kommandoran-mediaserver.js
:
const { NodeMediaServer } = require('node-media-server');
const config = {
logType: 3, // 3 - Log everything (debug)
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 60,
ping_timeout: 30
},
http: {
port: 8000,
allow_origin: '*'
},
relay: {
ffmpeg: '/usr/local/bin/ffmpeg',
tasks: [
{
app: 'cctv',
mode: 'static',
edge: 'rtsp://<USER>:<PASSWORD>@10.0.0.111/live1.sdp',
name: 'uterum',
rtsp_transport : 'tcp' //['udp', 'tcp', 'udp_multicast', 'http']
}
]
}
};
var nms = new NodeMediaServer(config)
nms.run();
My problem and question
When I try to view camera.html
(see markup above) via the Chromium browser on Raspberry Pi (i.e. local host), nothing is displayed. In the Chromium debug inspector there are no javascript errors, but I get this:
GET http://localhost:8000/live/uterum.flv net::ERR_EMPTY_RESPONSE
Here is a screenshot from the node terminal:
The red area illustrates the output when I try to make a request to http://localhost:8000/live/uterum.flv
.
I suppose I try to reach the wrong endpoint but which is correct? The documentation states http://localhost:8000/live/STREAM_NAME.flv
. What is "STREAM_NAME
" in my case?
1 Answer
Reset to default 3As you can see from the configuration, your RTSP stream is pushed to the ‘cctv’ application.
So your playback address should be:
rtmp://localhost/cctv/uterum
or
http://localhost:8000/cctv/uterum.flv
本文标签:
版权声明:本文标题:javascript - Re-stream RTSP from IP cam with Node Media Server to httpws and display it with html - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742266786a2443551.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论