【发布时间】:2019-08-02 15:45:20
【问题描述】:
我希望能够在网络上查看闭路电视屏幕。
我一直在从事一个允许在网络上查看网络摄像机的项目。 然后我被要求让同轴相机在网络上可见。 所以我决定使用DVR。 首先,我将 DVR 连接到路由器。 然后同轴摄像机的输入被DVR接收,DVR通过路由器传输信息。 通过这个过程,我确认 rtsp 工作正常。 但它在网络上不起作用。
我目前正在使用 nginx 网络服务器。 并使用 ffmpeg 将 rtsp 信息发送到我的 nginx Web 服务器上的 rtmp。 然后,Web 服务器会将其转换为 hls (index.m3u8) 文件。 我认为在此过程中出了点问题。
Nginx RTMP 配置
# RTMP Config
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
application live{
live on;
deny play all;
push rtmp://localhost/play;
on_publish http://localhost:3001/api/on-live-auth;
on_publish_done http://localhost:3001/api/on-live-done;
}
application play {
live on;
# Turn on HLS
hls on;
hls_nested on;
hls_fragment_naming system;
hls_path /home/banana/nginx/live;
hls_fragment 3;
hls_playlist_length 60;
# disable consuming the stream from nginx as rtmp
#deny play all;
}
}
}
# End RTMP Config
FFMPEG 命令
ffmpeg -i rtsp://<cameraIp> -c:v copy -rtsp_transport tcp -preset veryfast -c:a copy -fflags +igndts+genpts -f flv rtmp://localhost/live/<cameraId>
测试结果
IP 摄像机 RTSP 地址 = admin:qwerty1.@ssnet4.iptime.org:555/trackID=3
DVR RTSP 地址 = admin:hrd-442s@hwakptz.iptime.org:4524/1
分别在vlc播放器中运行上述rtsp地址
成功:IP Camera RTSP 地址,DVR RTSP 地址
IP 摄像头 HLS 地址 = http://168.131.150.80:4567/live/5c28ae28c6cd0c6c329e1ebc/index.m3u8
DVR HLS 地址 = http://168.131.150.80:4567/live/5c8746c9d7d74a600edf2460/index.m3u8
分别在vlc播放器中运行上述rtsp地址
成功:IP 摄像机 HLS 地址
失败:DVR HLS 地址
这与 react 播放器的结果相同。
const streamUrl = `http://168.131.150.80:4567/live/<cameraId>/index.m3u8`;
<ReactPlayer
onClick={this._onClickFullscreen}
width={"100%"}
height={"100%"}
url={streamUrl}
playing={true}
controls={false}
muted={true}
/>
问题
- 有没有办法直接在网络上查看 rtsp?
- 出了什么问题,还有什么问题?
【问题讨论】:
标签: javascript reactjs nginx ffmpeg http-live-streaming