keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.68k stars 235 forks source link

Hikvision and Smart Detection with Frigate #61

Closed hallengreenn closed 3 years ago

hallengreenn commented 3 years ago

Hello there,

I have successfully setup HA, Mosquitto, Frigate and Unifi-cam-proxy. It looks fine from UniFi Protect both on WebUI and Phone app -

But when trying to see the clip from either WebUI or phone, it ends up stalling saying 'Connection taking longer than suspected'

In Frigate, I can see both snapshots and clips so from there it's working but something is off in UniFi. Also, if I try to download from UniFi - it's only 45 bytes...

UniFi-Cam-Proxy command: docker run -d --name "UniFi-bryggers-test" -v "E:\Docker\Config\unifi-cam-proxy\client.pem:/client.pem" keshavdv/unifi-cam-proxy unifi-cam-proxy --verbose --host "192.168.254.9" --mac 'AA:BB:CC:22:33:44' --model 'UVC G4 Pro'--fw-version '4.34.22' --name "bryggers" --ip "192.168.254.90" --cert /client.pem --token "rvrkMFUhcl9QM5oHhpCWWUKEBpjrc1gJ" frigate -s "rtsp://admin:Passw0rd@192.168.254.90:554/Streaming/Channels/101/" --mqtt-host "192.168.254.249" --frigate-camera "bryggers"

I'm not sure, where to troubleshoot but I will happly help where I can. Setup: UniFi Cloudkey Gen2+ Hikvision DS-2CD2185FWD-I

Best regards

hallengreenn commented 3 years ago

I can see it's the same issue, if I use the RTSP stream with the API for start/stop recording. Those files are also corrupted.

I tried with the following settings: docker run -d -p 2222:2222 --name "UniFi-bryggers-test" -v "E:\Docker\Config\unifi-cam-proxy\client.pem:/client.pem" keshavdv/unifi-cam-proxy unifi-cam-proxy --verbose --host "192.168.254.9" --mac 'AA:BB:CC:22:33:44' --model 'UVC G4 Pro'--fw-version '4.34.22' --name "bryggers" --ip "192.168.254.90" --cert /client.pem --token "rvrkMFUhcl9QM5oHhpCWWUKEBpjrc1gJ" rtsp -s "rtsp://admin:Passw0rd@192.168.254.90:554/Streaming/Channels/101/" --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=2206/100:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k'--http-api "2222"

keshavdv commented 3 years ago

Does the live stream work at all on the app or browser?

hallengreenn commented 3 years ago

Does the live stream work at all on the app or browser?

Yes it does. However after a restart it all started working (including recording to UniFi), I don't know what the problem was/is. Or how to get the logs if it was supposed to happen again.

On another note, what ffmpeg-args would be correct for my camera? From what I read in previously threads, the tickerrate should be double the FPS so something like this? --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=40:fixed_frame_rate_flag=1" -an

Input #0, rtsp, from 'rtsp://admin:Passw0rd@192.168.254.146:554/Streaming/Channels/101/':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 2.150000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 20 fps, 20 tbr, 90k tbn, 40 tbc
keshavdv commented 3 years ago

Those additional options are only necessary if the stream doesn't already contain appropriate markers that Protect expects. If it works without them, that will require the least amount of resources since there will be no modification of the original stream at all. For the Hikvision I tested with, I didn't end up needing them, so I'd recommend trying to remove them.

hallengreenn commented 3 years ago

Those additional options are only necessary if the stream doesn't already contain appropriate markers that Protect expects. If it works without them, that will require the least amount of resources since there will be no modification of the original stream at all. For the Hikvision I tested with, I didn't end up needing them, so I'd recommend trying to remove them.

I think the problem with not recording is running deeper, I found threads on unifi forum and reddit, whom had the same problems with unifi cameras. So seems to be a common problem, I close it for now. :)

thanks for the help and the great tool!

jkblm commented 3 years ago

@hallengreenn

I have unifi-cam-proxy running well on RBPi4B/4GB (running current Rasberry Pi O/S) with 5 Hikvision cameras in Unifi UNVR Protect 1.9.0

I am able to get Frigate/MQTT install on a second RPi4B with Home Assistant. This Also works well. But I have not been successful installing unifi-cam-proxy on Home Assistant.

How did you install unifi-cam-proxy on to Home Assistant?

Thanks in advance!