Restream
RTSP
Frigate 可以将您的视频流重新作为 RTSP 流,供 Home Assistant 等其它应用程序在 rtsp://<frigate_host>:8554/<camera_name>
上使用。端口 8554 必须打开。这允许您同时使用 Frigate 和 Home Assistant 实况视图中的视频流进行检测,而无需与摄像机建立两个单独的连接。视频流直接从原始视频流复制,以避免重新编码。此视频流不包括 Frigate 的任何标注。
Frigate 使用 go2rtc 提供的 restream 和 MSE/WebRTC 功能。go2rtc 配置位于配置中的 go2rtc
,更多高级配置和功能请参阅 go2rtc 文档。
您可以访问 http://frigate_ip:5000/api/go2rtc/streams
上的 go2rtc 流信息,它有助于调试并提供有关摄像机流的有用信息。
鸟瞰 Restream
可通过 rtsp://<frigate_host>:8554/birdseye
访问鸟瞰 RTSP restream。启用鸟瞰 restream 将导致鸟瞰全天候运行,这可能会在一定程度上增加 CPU 占用率。
birdseye:
restream: true
通过身份验证确保 Restream 安全
go2rtc Restream可通过基于 RTSP 的用户名/密码验证来确保安全。例如:
go2rtc:
rtsp:
username: "admin"
password: "pass"
streams: ...
注意: 这不适用于本地主机请求,使用重流作为 Frigate 摄像机的来源时无需提供凭据。
减少与摄像机的连接
有些摄像机只支持一个活动连接,或者您可能只想为摄像机打开一个连接。RTSP restream 可以实现这一点。
单流
单流连接到摄像机。单流 restream,detect
和 record
连接到restream。
go2rtc:
streams:
name_your_rtsp_cam: # <- 用于 RTSP 流
- rtsp://192.168.1.5:554/live0 # <- 支持视频和 AAC 音频的数据流
- "ffmpeg:name_your_rtsp_cam#audio=opus" # <- 将音频转码为缺失编解码器(通常为 opus)的流副本
name_your_http_cam: # <- 用于其它流
- http://192.168.50.155/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=user&password=password # <- stream which supports video & aac audio
- "ffmpeg:name_your_http_cam#audio=opus" # <- 将音频转码为缺失编解码器(通常为 opus)的流副本
cameras:
name_your_rtsp_cam:
ffmpeg:
output_args:
record: preset-record-generic-audio-copy
inputs:
- path: rtsp://127.0.0.1:8554/name_your_rtsp_cam # <--- the name here must match the name of the camera in restream
input_args: preset-rtsp-restream
roles:
- record
- detect
- audio # <- only necessary if audio detection is enabled
name_your_http_cam:
ffmpeg:
output_args:
record: preset-record-generic-audio-copy
inputs:
- path: rtsp://127.0.0.1:8554/name_your_http_cam # <--- the name here must match the name of the camera in restream
input_args: preset-rtsp-restream
roles:
- record
- detect
- audio # <- only necessary if audio detection is enabled
子流
摄像机有两个连接。一个连接子码流,一个连接其余码流,record
连接其余码流。
go2rtc:
streams:
name_your_rtsp_cam:
- rtsp://192.168.1.5:554/live0 # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg
- "ffmpeg:name_your_rtsp_cam#audio=opus" # <- copy of the stream which transcodes audio to opus
name_your_rtsp_cam_sub:
- rtsp://192.168.1.5:554/substream # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg
- "ffmpeg:name_your_rtsp_cam_sub#audio=opus" # <- copy of the stream which transcodes audio to opus
name_your_http_cam:
- http://192.168.50.155/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=user&password=password # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg
- "ffmpeg:name_your_http_cam#audio=opus" # <- copy of the stream which transcodes audio to opus
name_your_http_cam_sub:
- http://192.168.50.155/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=user&password=password # <- stream which supports video & aac audio. This is only supported for rtsp streams, http must use ffmpeg
- "ffmpeg:name_your_http_cam_sub#audio=opus" # <- copy of the stream which transcodes audio to opus
cameras:
name_your_rtsp_cam:
ffmpeg:
output_args:
record: preset-record-generic-audio-copy
inputs:
- path: rtsp://127.0.0.1:8554/name_your_rtsp_cam # <--- the name here must match the name of the camera in restream
input_args: preset-rtsp-restream
roles:
- record
- path: rtsp://127.0.0.1:8554/name_your_rtsp_cam_sub # <--- the name here must match the name of the camera_sub in restream
input_args: preset-rtsp-restream
roles:
- audio # <- only necessary if audio detection is enabled
- detect
name_your_http_cam:
ffmpeg:
output_args:
record: preset-record-generic-audio-copy
inputs:
- path: rtsp://127.0.0.1:8554/name_your_http_cam # <--- the name here must match the name of the camera in restream
input_args: preset-rtsp-restream
roles:
- record
- path: rtsp://127.0.0.1:8554/name_your_http_cam_sub # <--- the name here must match the name of the camera_sub in restream
input_args: preset-rtsp-restream
roles:
- audio # <- only necessary if audio detection is enabled
- detect
高级 Restream 配置
go2rtc 中的 exec 源可用于自定义 ffmpeg 命令。下面就是一个例子:
注意:输出需要用两个大括号 {{output}}
传递
go2rtc:
streams:
stream1: exec:ffmpeg -hide_banner -re -stream_loop -1 -i /media/BigBuckBunny.mp4 -c copy -rtsp_transport tcp -f rtsp {{output}}