keshavdv / unifi-cam-proxy

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

Hikvision cam not working #182

Closed nicx closed 2 years ago

nicx commented 2 years ago

I want to use hikvision integration with this command:

unifi-cam-proxy --host 192.168.0.250 -i 192.168.1.10 --cert /client.pem --token *** hikvision -u *** -p ***

Video is not working, screenshots are. It is a DS-2CD2542FWD-IWS Hikvision dome cam.

This is the log output:

2022-02-16 06:38:42 b4cda1f72e61 HikvisionCam[1] INFO Spawning ffmpeg for video2 (8TQZyHjfoUvlhJcI): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -stimeout 15000000 -rtsp_transport udp -i "rtsp://***:***@192.168.1.10:554/Streaming/Channels/103/" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamname=8TQZyHjfoUvlhJcI -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 192.168.0.250 7550

2022-02-16 06:38:42 b4cda1f72e61 HikvisionCam[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-02-16 06:38:42 b4cda1f72e61 HikvisionCam[1] WARNING Previous ffmpeg process for video3 died.
mrMiimo commented 2 years ago

the channel is wrong, it shouldn't be 103, but 101 or 102 Do you use an NVR too?

nicx commented 2 years ago

@mrMiimo no, its directly configured. but its the same error message in the log with 101 and 102, too.

mrMiimo commented 2 years ago

if you open this rtsp://***:***@192.168.1.10:554/Streaming/Channels/103/ with VLC does it work?

nicx commented 2 years ago

@mrMiimo yes this works, but only when using /101 or /102. As I said before, in the logfile I have the same error for all 3 streams. (video1, video2 and video3).

mrMiimo commented 2 years ago

As I said before… if you look at the 1st line of your log, channel is setting /103… I don't know if you can change it. i use docker and i can set the channel as i like

nicx commented 2 years ago

@mrMiimo I am using docker compose. So how do you change this?

mrMiimo commented 2 years ago

in the command: don’t use hikvision option, use rtsp

nicx commented 2 years ago

ok. that for sure working. but with rstp I dont have the other features like motion etc. so that is not a solution, and thats why I opened this bug report for the hikvision integration ;)

keshavdv commented 2 years ago

Try adding --substream 2 when using the hikvision implementation to use 102 as the source for the lower profile stream rather than 103

mrMiimo commented 2 years ago

ok. that for sure working. but with rstp I dont have the other features like motion etc. so that is not a solution, and thats why I opened this bug report for the hikvision integration ;)

yes i know, i just need to record. for the movements I integrated the cameras with Homekit secure video

mrMiimo commented 2 years ago

Try adding --substream 2 when using the hikvision implementation to use 102 as the source for the lower profile stream rather than 103

Ohhh, --substream 2 in command:?

nicx commented 2 years ago

@keshavdv great hint, thanks. that works! "bug" closed 👍 @mrMiimo yes exactly

mrMiimo commented 2 years ago

@keshavdv it didn't work for me, maybe because I have an NVR in between. For streaming only this url works: rtsp://admin:XXXXXXXXX@192.168.1.244:554/Streaming/Unicast/channels/401 or 101, 102, 201, 202, 301, 302, 401, 402 (I have 4 cameras)

Logs:

2022-02-23T20:47:14 2022-02-23 20:47:14 4ab2a23ce1ae HikvisionCam[1] INFO Spawning ffmpeg for video3 (5Pkn78Fw9XecMziq): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -stimeout 15000000 -rtsp_transport tcp -i "rtsp://admin:XXXXXXXX@192.167.1.244:554/Streaming/Channels/101/" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamname=5Pkn78Fw9XecMziq -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 192.168.1.1 7550
2022-02-23T20:47:14 2022-02-23 20:47:14 4ab2a23ce1ae HikvisionCam[1] INFO Processing [GetSystemStats] message
2022-02-23T20:47:14 2022-02-23 20:47:14 4ab2a23ce1ae HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-23T20:47:14 2022-02-23 20:47:14 4ab2a23ce1ae HikvisionCam[1] INFO Connecting to motion events API
2022-02-23T20:47:16 2022-02-23 20:47:16 4ab2a23ce1ae HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-23T20:47:16 2022-02-23 20:47:16 4ab2a23ce1ae HikvisionCam[1] INFO Connecting to motion events API
2022-02-23T20:47:18 2022-02-23 20:47:18 4ab2a23ce1ae HikvisionCam[1] INFO Processing [NetworkStatus] message
2022-02-23T20:47:19 2022-02-23 20:47:19 4ab2a23ce1ae HikvisionCam[1] INFO Processing [GetSystemStats] message
2022-02-23T20:47:19 2022-02-23 20:47:19 4ab2a23ce1ae HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-23T20:47:19 2022-02-23 20:47:19 4ab2a23ce1ae HikvisionCam[1] INFO Connecting to motion events API
2022-02-23T20:47:21 2022-02-23 20:47:21 4ab2a23ce1ae HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-23T20:47:21 2022-02-23 20:47:21 4ab2a23ce1ae HikvisionCam[1] INFO Connecting to motion events API
2022-02-23T20:47:24 2022-02-23 20:47:24 4ab2a23ce1ae HikvisionCam[1] INFO Processing [ChangeVideoSettings] message
2022-02-23T20:47:24 2022-02-23 20:47:24 4ab2a23ce1ae HikvisionCam[1] INFO Processing [ChangeVideoSettings] message
2022-02-23T20:47:24 2022-02-23 20:47:24 4ab2a23ce1ae HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-23T20:47:24 2022-02-23 20:47:24 4ab2a23ce1ae HikvisionCam[1] INFO Connecting to motion events API
2022-02-23T20:47:26 2022-02-23 20:47:26 4ab2a23ce1ae HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-23T20:47:26 2022-02-23 20:47:26 4ab2a23ce1ae HikvisionCam[1] INFO Connecting to motion events API
2022-02-23T20:47:28 2022-02-23 20:47:28 4ab2a23ce1ae HikvisionCam[1] INFO Processing [NetworkStatus] message
2022-02-23T20:47:28 2022-02-23 20:47:28 4ab2a23ce1ae HikvisionCam[1] INFO Processing [GetRequest] message
2022-02-23T20:47:29 [tcp @ 0x76b38560] Connection to tcp://192.167.1.244:554?timeout=15000000 failed: Operation timed out
2022-02-23T20:47:29 rtsp://admin:XXXXXXXX@192.167.1.244:554/Streaming/Channels/101/: Operation timed out
2022-02-23T20:47:29 [tcp @ 0x76b6d560] Connection to tcp://192.167.1.244:554?timeout=15000000 failed: Operation timed out
2022-02-23T20:47:29 rtsp://admin:XXXXXXXX@192.167.1.244:554/Streaming/Channels/101/: Operation timed out
2022-02-23T20:47:29 2022-02-23 20:47:29 4ab2a23ce1ae HikvisionCam[1] ERROR Motion API request failed, retrying
keshavdv commented 2 years ago

If you're using an NVR, use --channel 4 to select streams 401 and 403 or a combination of --channel and --substream to select the appropriate streams.

mrMiimo commented 2 years ago

@keshavdv I tried and it works! I can set the channel and streams I need. But streaming video and API don't work.. In the logs I can see that a URL is used that doesn't work if I try to open it in VLC. Is there any way to change the URL like with the rtsp setting?

Log:

2022-02-24T08:05:16 2022-02-24 08:05:16 97a4feba2ba6 HikvisionCam[1] INFO Connecting to motion events API
2022-02-24T08:05:19 [tcp @ 0x76bbf560] Connection to tcp://192.167.1.244:554?timeout=15000000 failed: Operation timed out
2022-02-24T08:05:19 rtsp://admin:XXXXXXXX@192.167.1.244:554/Streaming/Channels/401/: Operation timed out
2022-02-24T08:05:19 [tcp @ 0x76b09560] Connection to tcp://192.167.1.244:554?timeout=15000000 failed: Operation timed out

2022-02-24T08:05:19 rtsp://admin:XXXXXXXX@192.167.1.244:554/Streaming/Channels/402/: Operation timed out

2022-02-24T08:05:19 [tcp @ 0x76b4b560] Connection to tcp://192.167.1.244:554?timeout=15000000 failed: Operation timed out

2022-02-24T08:05:19 rtsp://admin:XXXXXXXX@192.167.1.244:554/Streaming/Channels/402/: Operation timed out

2022-02-24T08:05:20 2022-02-24 08:05:20 97a4feba2ba6 HikvisionCam[1] ERROR Motion API request failed, retrying

2022-02-24T08:05:20 2022-02-24 08:05:20 97a4feba2ba6 HikvisionCam[1] INFO Connecting to motion events API
2022-02-24T08:05:20 2022-02-24 08:05:20 97a4feba2ba6 HikvisionCam[1] INFO Processing [NetworkStatus] message
2022-02-24T08:05:20 2022-02-24 08:05:20 97a4feba2ba6 HikvisionCam[1] INFO Processing [GetSystemStats] message
2022-02-24T08:05:22 2022-02-24 08:05:22 97a4feba2ba6 HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-24T08:05:22 2022-02-24 08:05:22 97a4feba2ba6 HikvisionCam[1] INFO Connecting to motion events API
2022-02-24T08:05:25 2022-02-24 08:05:25 97a4feba2ba6 HikvisionCam[1] ERROR Motion API request failed, retrying
2022-02-24T08:05:25 2022-02-24 08:05:25 97a4feba2ba6 HikvisionCam[1] INFO Connecting to motion events API
2022-02-24T08:05:25 2022-02-24 08:05:25 97a4feba2ba6 HikvisionCam[1] INFO Processing [ChangeVideoSettings] message