websocket JSMpeg无法从RTSP获取流

m4pnthwp  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(138)

我试图得到一个网页内的RTSP流,但实际上没有成功.
为此,我完全遵循JSMpeg的教程:https://github.com/phoboslab/jsmpeg
使用自定义FFMPEG命令:

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

字符串
我的WebSocket很好地接收我的连接。
但我的画布仍然是一个白色正方形:

奇怪的是,当我在代码中使用假URL更改WebSocket URL时,画布变为黑色。

所以我猜它在收到东西的时候会变白色。
谢谢你的帮助

tvmytwxo

tvmytwxo1#

很可能你已经解决了这个问题,只是把这些留给其他遇到同样问题的人。
在我的例子中,我忘记了在新创建的流对象上调用start()
下面的函数是我创建的一个对象的一部分,用于在instantiate中跟踪流,对于多客户端多流情况很有用。

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")
        }
    }

字符串

相关问题