Fix ONVIF support for Unifi
Hello everyone, I think i figured out why the AI Port doesn't play nicely with go2rtc, the AI Port seems to be expecting a valid RateControl in the ONVIF payload, however go2rtc returns an empty <tt:RateControl /> instead of something like:
<tt:RateControl>
<tt:FrameRateLimit>20</tt:FrameRateLimit>
<tt:EncodingInterval>1</tt:EncodingInterval>
<tt:BitrateLimit>12000</tt:BitrateLimit>
</tt:RateControl>
The following error can be observed in the Protect logs (service.log)
2025-12-20T19:05:11.200Z - error: Failed to restart stream for go2rtc [84470971D631 @ 192.168.1.88] Channel fps is not found
Error: Channel fps is not found
at Object.ok (/usr/share/unifi-protect/app/webpack:/unifi-protect/src/core/lib/assert.ts:9:11)
at t.restartStream (/usr/share/unifi-protect/app/webpack:/unifi-protect/src/middleware/devices/aiPorts/subscribers/restartStream.ts:66:14)
at process.response (node:internal/process/task_queues:95:5)
at response (/usr/share/unifi-protect/app/webpack:/unifi-protect/src/middleware/devices/aiPorts/helpers/pairCamera.ts:81:11)
at result (/usr/share/unifi-protect/app/webpack:/unifi-protect/src/middleware/devices/aiPorts/subscribers/pairCameras.ts:33:11)
at /usr/share/unifi-protect/app/webpack:/unifi-protect/src/middleware/metrics/helpers/withLabeledExecutionMetric.ts:21:13
Its also worth noting that even assuming this gets implemented, the AI Port might still not play nicely as the ONVIF server advertises 1080p resolution regardless of the actual stream resolution.
(On a side note, it looks like Protect supports 2-way audio over ONVIF?? would be cool if we could get that working)
2025-12-20T19:10:56.333Z - info: Talkback using UDP/AAC 2-way audio settings {"typeFmt":"aac","typeIn":"serverudp","bindAddr":"0.0.0.0","bindPort":7004,"filterAddr":null,"filterPort":null,"channels":1,"samplingRate":22050,"bitsPerSample":16,"quality":100} for camera go2rtc [84470971D631 @ 192.168.1.88]
Originally posted by @knackrack615 in https://github.com/AlexxIT/go2rtc/issues/1538#issuecomment-3678062588