keshavdv / unifi-cam-proxy

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

Add hikvison camera over frigate doesn't work #165

Closed mihalich1988 closed 2 years ago

mihalich1988 commented 2 years ago

Describe the bug

2022-01-25 13:10:48 fac80e52799d FrigateCam[1] INFO Spawning stream for snapshots: ffmpeg -nostdin -y -re -rtsp_transport tcp -i "rtsp://admin:password@172.16.0.118:554/Streaming/Channels/101" -vf fps=1 -update 1 /tmp/tmps05hp00h/screen.jpg
2022-01-25 13:10:48 fac80e52799d Core[1] INFO Creating ws connection to wss://192.168.77.200:7442/camera/1.0/ws?token=7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv
2022-01-25 13:10:48 fac80e52799d FrigateCam[1] INFO Adopting with token [7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv] and mac [AABBCCDDEE01]
2022-01-25 13:10:48 fac80e52799d FrigateCam[1] INFO Connected to 192.168.77.215:1883
2022-01-25 13:10:48 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_hello] message
2022-01-25 13:10:48 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_hello] message
2022-01-25 13:10:48 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
2022-01-25 13:10:48 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
2022-01-25 13:10:49 fac80e52799d FrigateCam[1] INFO Cleaning up instance
2022-01-25 13:10:49 fac80e52799d Core[1] INFO Backing off connect(...) for 2.0s (True)
2022-01-25 13:10:51 fac80e52799d Core[1] INFO Creating ws connection to wss://192.168.77.200:7442/camera/1.0/ws?token=7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv
2022-01-25 13:10:51 fac80e52799d Core[1] INFO Backing off connect(...) for 4.0s (True)
2022-01-25 13:10:55 fac80e52799d Core[1] INFO Creating ws connection to wss://192.168.77.200:7442/camera/1.0/ws?token=7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv
2022-01-25 13:10:55 fac80e52799d Core[1] INFO Backing off connect(...) for 8.0s (True)
2022-01-25 13:11:03 fac80e52799d Core[1] INFO Creating ws connection to wss://192.168.77.200:7442/camera/1.0/ws?token=7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv
2022-01-25 13:11:03 fac80e52799d Core[1] INFO Backing off connect(...) for 10.0s (True)
2022-01-25 13:11:13 fac80e52799d Core[1] INFO Creating ws connection to wss://192.168.77.200:7442/camera/1.0/ws?token=7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv
2022-01-25 13:11:13 fac80e52799d Core[1] INFO Backing off connect(...) for 10.0s (True)
2022-01-25 13:11:23 fac80e52799d Core[1] INFO Creating ws connection to wss://192.168.77.200:7442/camera/1.0/ws?token=7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv
2022-01-25 13:11:23 fac80e52799d FrigateCam[1] INFO Adopting with token [7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv] and mac [AABBCCDDEE01]
2022-01-25 13:11:23 fac80e52799d FrigateCam[1] INFO Connected to 192.168.77.215:1883
2022-01-25 13:11:23 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_hello] message
2022-01-25 13:11:23 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_hello] message
2022-01-25 13:11:23 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
2022-01-25 13:11:23 fac80e52799d FrigateCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
2022-01-25 13:11:24 fac80e52799d FrigateCam[1] INFO Cleaning up instance
2022-01-25 13:11:24 fac80e52799d Core[1] INFO Backing off connect(...) for 10.0s (True)

UniFi Cloudkey Gen2+ Cloud Key Plus 2.3.10

When log Backing off connect(...) - UI of Protect is down!

Direct connect to camera over RTSP is working fine!

To Reproduce docker run --rm -v "/root/unifi-proxy/client.pem:/client.pem" keshavdv/unifi-cam-proxy unifi-cam-proxy --ip "172.16.0.118" --host "192.168.77.200" --cert /client.pem --token "7bvIhIpFoCZBL1itL9DeIRE0A4SlytBv" --mac "AABBCCDDEE01" --model "UVC G4 Pro" --fw-version "4.46.18" frigate -s rtsp://admin:password@172.16.0.118:554/Streaming/Channels/101 --frigate-camera doorbell --mqtt-host 192.168.77.215 --mqtt-port 1883

Camera (please complete the following information):

keshavdv commented 2 years ago

Which version of the proxy and Protect are you running?

mihalich1988 commented 2 years ago

Protect version is 1.20.3 proxy is keshavdv/unifi-cam-proxy (i think is latest...)

mihalich1988 commented 2 years ago

Update to dev version ) Work, but now another problem with ffmpeg...

ffmpeg version 4.1.6 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8.3.0 (Alpine 8.3.0)
  configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --disable-debug
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
2022-01-25 16:51:28 bb852c29924d FrigateCam[1] WARNING Previous ffmpeg process for video3 died.
2022-01-25 16:51:28 bb852c29924d FrigateCam[1] INFO Spawning ffmpeg for video3 (6qCjIhytOpj9ljyF): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -stimeout 15000000 -rtsp_transport udp -i "rtsp://admin:qwerty123@172.16.0.118:554/Streaming/Channels/101" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamname=6qCjIhytOpj9ljyF -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 192.168.77.200 7550
2022-01-25 16:51:38 bb852c29924d FrigateCam[1] INFO Processing [NetworkStatus] message
2022-01-25 16:51:38 bb852c29924d FrigateCam[1] INFO Processing [GetSystemStats] message
2022-01-25 16:51:48 bb852c29924d FrigateCam[1] INFO Processing [NetworkStatus] message
2022-01-25 16:51:48 bb852c29924d FrigateCam[1] INFO Processing [GetSystemStats] message
2022-01-25 16:51:58 bb852c29924d FrigateCam[1] INFO Processing [NetworkStatus] message
2022-01-25 16:51:58 bb852c29924d FrigateCam[1] INFO Processing [GetSystemStats] message
2022-01-25 16:51:58 bb852c29924d FrigateCam[1] INFO Processing [ChangeVideoSettings] message
ffmpeg version 4.1.6 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8.3.0 (Alpine 8.3.0)
  configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --disable-debug
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
2022-01-25 16:51:58 bb852c29924d FrigateCam[1] WARNING Previous ffmpeg process for video3 died.
mihalich1988 commented 2 years ago

For frigate work ffmpeg: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport udp -stimeout 5000000 -use_wallclock_as_timestamps 1

GhostlyCrowd commented 2 years ago

If you run this command manually what is the output.

ffmpeg -nostdin -loglevel debug -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -stimeout 15000000 -rtsp_transport udp -i "rtsp://admin:qwerty123@172.16.0.118:554/Streaming/Channels/101" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamname=6qCjIhytOpj9ljyF -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 192.168.77.200 7550

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.