提问人:Daskis 提问时间:11/4/2023 更新时间:11/4/2023 访问量:11
将本地 RTSP 流重定向到 React 应用程序
Redirecting local RTSP stream to React application
问:
RTSP 流部署在从 USB 摄像头广播视频的本地网络上。一切都通过 VLC 媒体播放器进行。如何在 nest.js 后端获取 RTSP 流并将其重定向到前端(从后端获取它是必需的,因为不仅前端会使用该流)。React
我在服务器上试过这个
const NodeMediaServer = require('node-media-server');
const config = {
rtmp: {
port: 1488,
chunk_size: 60000,
gop_cache: false,
ping: 60,
ping_timeout: 30,
},
http: {
port: 6666,
allow_origin: '*',
},
relay: {
ffmpeg: './ffmpeg-master-latest-win64-gpl/bin/ffmpeg.exe',
tasks: [
{
app: 'live',
mode: 'static',
edge: `rtsp://192.168.1.238:8554/mystream`,
},
],
},
};
const nms = new NodeMediaServer(config);
nms.run();
nms.on('prePublish', (id, streamPath, args) => {
if (streamPath.indexOf('mystream') === -1) {
nms.getSession(id).reject();
}
});
console.log('Node Media Server is running');
而这个在React
import { Player, ControlBar } from 'video-react';
function App() {
return (
<div>
<Player
playsInline
autoPlay
src="http://localhost:8001/live/mystream.m3u8"
>
<ControlBar autoHide={false}/>
</Player>
</div>
)
}
export default App;
答: 暂无答案
评论