JSMpeg not able to get stream from RTSP

1.4k Views Asked by At

i'm trying to get a RTSP stream inside a webpage, but with no success actually.

For this I followed exactly the tutorial of JSMpeg : https://github.com/phoboslab/jsmpeg

With a custom FFMPEG command :

ffmpeg -i "rtsp://myurl/media.smp" \
 -vcodec h264 -f mpegts -codec:v mpeg1video -s 1290x980 -b:v 8000k \
 -r 25 -max_muxing_queue_size 9999 http://localhost:8081/supersecret

My websocket well receive my connection on it.

But my canvas is still a white square : enter image description here

The weird thing is when I change the websocket url with a false one, in my code, the canvas turn to black.

So I guess that it turn WHITE when it receive something.

Thansk for help

1

There are 1 best solutions below

0
On

Most likely you'll have fixed this already, just leaving these here for others that come across the same issue.

In my case i was forgetting the call to start() on the newly create stream object.

The function below is part of an object I created to keep track of the streams in instantiate, useful for multiclient multistream situation.

createStream: async function (rtspURL) {
        const myPort=9999
        console.log(`Assigning port ${myPort} to new stream` );
        try {
            this.streams[rtspURL] = new Stream({
                name: 'stream:'+rtspURL,
                url: rtspURL,
                wsPort: myPort
            });
            console.log("New stream instance created");
            console.log(this.streams[rtspURL] );
            this.streams[rtspURL].start();
            return myPort;
        } catch (error) {
            console.error("Error while instanciating new stream")
        }
    }