'Re-stream RTSP from IP cam with Node Media Server to http/ws and display it with html

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. enter image description here

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.com/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: enter image description here 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?



Solution 1:[1]

As 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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 StayOnTarget