问题描述
我正在尝试使用fluent-ffmpeg打开多个RTSP流,但是出现错误:
Error: Only one output stream is supported
我能够使用node-rtsp-stream
打开多个流,但是使用不同的websocket端口,但是我需要更多功能,因此我试图构建自己的项目。我注意到当我使用fluent-ffmpeg时,node-rtsp-stream使用child_process,但是我found a project也在使用fluent-ffmpeg,并且能够具有不同的流。
这是我的以下代码:
class Stream extends EventEmitter {
constructor(url) {
super();
this.startStream(url);
}
async startStream(url) {
const wss = new WebSocket.Server({ port: 8080 });
const name = Crypto.createHash("md5").update(url).digest("hex");
const command = ffmpeg(url)
.addInputoption("-rtsp_transport","tcp","-buffer_size","102400")
.fps("24")
.outputoptions("-f","mpegts")
.on("error",(err) => {
console.log(err);
});
console.log("id",name);
wss.on("connection",(socket,req) => {
if (req.url === "/" + name) {
const ffstream = command.pipe();
ffstream.on("data",(data) => {
socket.send(data);
});
}
});
}
}
const cams = ["rtsp://someip:554/1","rtsp://someip2:554/1"];
cams.forEach((cam) => {
const s = new Stream(cam);
});
我在做错什么,如何打开多个流?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)