Closed AYahoo closed 10 months ago
Could you please post your config with the removed camera hosts/credentials?
Sure thing, thanks for the quick response:
{ "telegram": { "api_id": XXX, "api_hash": "XXX", "lang_code": "en", "token": "XXX", "chat_users": [ XXX ], "alert_users": [ XXX ], "startup_message_users": [ XXX ] }, "log_level": "DEBUG", "camera_list": { "cam_1": { "hidden": false, "description": "NW Corner", "hashtag": "NWCorner", "group": "Outside", "api": { "host": "http://192.168.31.217", "port": 65001, "auth": { "user": "XXX", "password": "XXX", "type": "digest_cached" }, "stream_timeout": 10 }, "rtsp_port": 554, "picture": { "on_demand": { "channel": 101 }, "on_alert": { "channel": 101 } }, "video_gif": { "on_demand": { "channel": 101, "record_time": 10, "rewind_time": 10, "tmp_storage": "/tmp", "loglevel": "error", "rtsp_transport_type": "tcp" }, "on_alert": { "channel": 101, "record_time": 10, "rewind_time": 10, "rewind": true, "tmp_storage": "/tmp", "loglevel": "error", "rtsp_transport_type": "tcp" } }, "alert": { "delay": 15, "motion_detection": { "enabled": false, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false }, "line_crossing_detection": { "enabled": false, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false }, "intrusion_detection": { "enabled": true, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false } }, "livestream": { "youtube": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_youtube" }, "telegram": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_telegram" }, "srs": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_srs" }, "dvr": { "enabled": false, "local_storage_path": "/data/dvr", "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_dvr", "upload": { "delete_after_upload": true, "storage": { "telegram": { "enabled": false, "group_id": -10000000 } } } }, "icecast": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "vp9.kitchen" } }, "command_sections_visibility": { "general": true, "infrared": true, "motion_detection": true, "line_detection": true, "intrusion_detection": true, "alert_service": true, "stream_youtube": true, "stream_telegram": true, "stream_icecast": true } }, "cam_2": { "hidden": false, "description": "Door", "hashtag": "Door", "group": "Outside", "api": { "host": "http://192.168.31.217", "port": 80, "auth": { "user": "XXX", "password": "XXX", "type": "digest_cached" }, "stream_timeout": 10 }, "rtsp_port": 554, "picture": { "on_demand": { "channel": 201 }, "on_alert": { "channel": 201 } }, "video_gif": { "on_demand": { "channel": 201, "record_time": 10, "rewind_time": 10, "tmp_storage": "/tmp", "loglevel": "error", "rtsp_transport_type": "tcp" }, "on_alert": { "channel": 201, "record_time": 10, "rewind_time": 10, "rewind": true, "tmp_storage": "/tmp", "loglevel": "error", "rtsp_transport_type": "tcp" } }, "alert": { "delay": 15, "motion_detection": { "enabled": false, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false }, "line_crossing_detection": { "enabled": false, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false }, "intrusion_detection": { "enabled": true, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false } }, "livestream": { "youtube": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_youtube" }, "telegram": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_telegram" }, "srs": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_srs" }, "dvr": { "enabled": false, "local_storage_path": "/data/dvr", "livestream_template": "tpl_kitchen", "encoding_template": "direct.kitchen_dvr", "upload": { "delete_after_upload": true, "storage": { "telegram": { "enabled": false, "group_id": -10000000 } } } }, "icecast": { "enabled": false, "livestream_template": "tpl_kitchen", "encoding_template": "vp9.kitchen" } }, "command_sections_visibility": { "general": true, "infrared": true, "motion_detection": true, "line_detection": true, "intrusion_detection": true, "alert_service": true, "stream_youtube": true, "stream_telegram": true, "stream_icecast": true } }, "cam_3": { "hidden": false, "description": "Front Yard", "hashtag": "FrontYard", "group": "Outside", "api": { "host": "http://192.168.31.217", "port": 65005, "auth": { "user": "XXX", "password": "XXX", "type": "digest_cached" }, "stream_timeout": 10 }, "rtsp_port": 554, "picture": { "on_demand": { "channel": 101 }, "on_alert": { "channel": 101 } }, "video_gif": { "on_demand": { "channel": 101, "record_time": 10, "rewind_time": 10, "tmp_storage": "/tmp", "loglevel": "error", "rtsp_transport_type": "tcp" }, "on_alert": { "channel": 101, "record_time": 10, "rewind_time": 10, "rewind": true, "tmp_storage": "/tmp", "loglevel": "error", "rtsp_transport_type": "tcp" } }, "alert": { "delay": 15, "motion_detection": { "enabled": false, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false }, "line_crossing_detection": { "enabled": false, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false }, "intrusion_detection": { "enabled": true, "sendpic": true, "fullpic": false, "send_videogif": true, "send_text": false } }, "livestream": { "youtube": { "enabled": false, "livestream_template": "tpl_basement", "encoding_template": "direct.basement_youtube" }, "telegram": { "enabled": false, "livestream_template": "tpl_basement", "encoding_template": "direct.basement_telegram" }, "srs": { "enabled": false, "livestream_template": "tpl_basement", "encoding_template": "direct.basement_srs" }, "dvr": { "enabled": false, "local_storage_path": "/data/dvr", "livestream_template": "tpl_basement", "encoding_template": "direct.basement_dvr", "upload": { "delete_after_upload": true, "storage": { "telegram": { "enabled": false, "group_id": -10000000 } } } }, "icecast": { "enabled": false, "livestream_template": "tpl_basement", "encoding_template": "vp9.basement" } }, "command_sections_visibility": { "general": true, "infrared": true, "motion_detection": true, "line_detection": true, "intrusion_detection": true, "alert_service": true, "stream_youtube": true, "stream_telegram": true, "stream_icecast": true } } } }
That's weird, I've emulated NVR with my two cameras but everything looks good. I've noticed that you have the same rtsp_port
for each of your cameras. I suppose they are different when connecting to NVR.
I still couldn't reproduce the issue when I used the same rtsp_port
as in your config so please reproduce the issue again and show the logs (please remove your users/passwords from the log entries).
Sure thing, but let me explain the setup and the issue better, I have 3 cameras connected to an NVR, I have two way to connect to the cameras, one setup is:
Cam1 port 65001 channel 101 Cam2 port 65002 channel 101 Cam3 port 65003 channel 101
this way I connect to the camera directly through the NAT of the NVR and each one has it one ISAPI stream.
Second setup:
Cam1 port 80 channel 101 Cam2 port 80 channel 201 Cam3 port 80 channel 301
This way I connect to the NVR, and get all the data from the NVR system, Including the ISAPI stream and the OnAlert trigger. When I use this setup, and one of the events is triggered, all the cameras send alert (it seems like it doesn't filter from the stream which channel is the one that triggered the alarm).
I use this configuration (second setup) because not all my cameras are configurable to work directly.
This is the LOG, Config was, Cam1-3 "host": "http://192.168.31.217", "port": 80. Cam1 Channel 101 Cam2 Channel 201 Cam3 Channel 501
I've got it, thanks. Every camera has a separate running task to connect and monitor Alert Stream and with the second setup, each camera connects to the same Alert Stream URL http://192.168.31.217:80/ISAPI/Event/notification/alertStream
while current logic expects a unique URL (at least port), so the first setup would work.
Right now I'm not sure how to handle this but I suppose that the NVR Alert Stream payload contains something, that identifies which camera is triggering the event. Probably that's a channel number.
Could you please edit this file https://github.com/tropicoo/hikvision-camera-bot/blob/61c69c147a0f811b5a8748173284e834189afd1a/hikcamerabot/services/alarm/tasks/alarm_monitoring_task.py#L57
by adding a debug log line to the 57th line.
self._log.debug('Alert chunk for cam "%s": %s', self._cam.id, chunk)
like on the screenshot and rebuild/restart the bot and show the logs with triggered alert again:
I edited it: Restarted, but I don't get any 'Alert chunk'... on the log file.
Probably container wasn't rebuilt, try with this command:
docker compose up --build -t 0 -d && docker compose logs --tail 100 -f hikvision-camera-bot
2022-11-22 19:37:21,976 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=14 read=polling write=<idle, bufsize=0>> resumes reading 2022-11-22 19:37:30,974 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading 2022-11-22 19:37:30,976 - [DEBUG] - [ServiceAlarmMonitoringTask:57] - Alert chunk for cam "cam_1": --boundary Content-Type: application/xml; charset="UTF-8" Content-Length: 493
2022-11-22 19:37:30,980 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading 2022-11-22 19:37:30,987 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=13 read=idle write=<idle, bufsize=0>> pauses reading 2022-11-22 19:37:30,988 - [DEBUG] - [ServiceAlarmMonitoringTask:57] - Alert chunk for cam "cam_2": --boundary Content-Type: application/xml; charset="UTF-8" Content-Length: 493
2022-11-22 19:37:30,992 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=14 read=idle write=<idle, bufsize=0>> pauses reading 2022-11-22 19:37:30,993 - [DEBUG] - [ServiceAlarmMonitoringTask:57] - Alert chunk for cam "cam_3": --boundary Content-Type: application/xml; charset="UTF-8" Content-Length: 493
2022-11-22 19:37:30,996 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=13 read=polling write=<idle, bufsize=0>> resumes reading 2022-11-22 19:37:30,999 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=14 read=polling write=<idle, bufsize=0>> resumes reading 2022-11-22 19:37:33,547 - [DEBUG] - [asyncio:877] - <_SelectorSocketTransport fd=13 read=polling write=<idle, bufsize=0>> received EOF 2022-11-22 19:37:33,549 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=13 read=idle write=<idle, bufsize=0>> pauses reading 2022-11-22 19:37:33,552 - [DEBUG] - [asyncio:877] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> received EOF 2022-11-22 19:37:33,554 - [DEBUG] - [asyncio:877] - <_SelectorSocketTransport fd=14 read=polling write=<idle, bufsize=0>> received EOF 2022-11-22 19:37:33,562 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading 2022-11-22 19:37:33,567 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=14 read=idle write=<idle, bufsize=0>> pauses reading 2022-11-22 19:37:33,572 - [DEBUG] - [ServiceAlarmMonitoringTask:57] - Alert chunk for cam "cam_2": 2022-11-22 19:37:33,572 - [ERROR] - [ServiceAlarmMonitoringTask:37] - Unexpectedly exited from stream chunk processing loop for cam_2. Retrying in 0.5 seconds... 2022-11-22 19:37:33,574 - [DEBUG] - [ServiceAlarmMonitoringTask:57] - Alert chunk for cam "cam_1": 2022-11-22 19:37:33,574 - [ERROR] - [ServiceAlarmMonitoringTask:37] - Unexpectedly exited from stream chunk processing loop for cam_1. Retrying in 0.5 seconds... 2022-11-22 19:37:33,575 - [DEBUG] - [ServiceAlarmMonitoringTask:57] - Alert chunk for cam "cam_3": 2022-11-22 19:37:33,575 - [ERROR] - [ServiceAlarmMonitoringTask:37] - Unexpectedly exited from stream chunk processing loop for cam_3. Retrying in 0.5 seconds... 2022-11-22 19:37:34,074 - [INFO] - [ServiceAlarmMonitoringTask:27] - Starting alert pusher task for camera: "Door" 2022-11-22 19:37:34,076 - [DEBUG] - [AlertStreamEndpoint:148] - Alert Stream Request: GET - http://192.168.31.217:80/ISAPI/Event/notification/alertStream 2022-11-22 19:37:34,085 - [INFO] - [ServiceAlarmMonitoringTask:27] - Starting alert pusher task for camera: "NW Corner" 2022-11-22 19:37:34,086 - [DEBUG] - [AlertStreamEndpoint:148] - Alert Stream Request: GET - http://192.168.31.217:80/ISAPI/Event/notification/alertStream 2022-11-22 19:37:34,091 - [INFO] - [ServiceAlarmMonitoringTask:27] - Starting alert pusher task for camera: "Front Yard" 2022-11-22 19:37:34,092 - [DEBUG] - [AlertStreamEndpoint:148] - Alert Stream Request: GET - http://192.168.31.217:80/ISAPI/Event/notification/alertStream
Please try to trigger the alarm event, right now these logs only contain case when the monitoring task was restarted
I tried, it didn't show, once I disabled the notification it did show: Attached on the next comment
I triggered camera 501 (Cam_3)
Are these things configured in NVR?
2022-11-22T17:48:40.021383713Z <dynChannelID>5</dynChannelID>
2022-11-22T17:48:40.021396005Z <channelID>5</channelID>
2022-11-22T17:48:40.021488009Z <channelName>Front Yard</channelName>
dynChannelID, channelID these two i think it has to do with the physical port that the camera is connected to in the NVR.
the name is configurable.
Okay, I will add a new configuration section for such NVR setup, so we could write channelName
for a particular camera and filter the events by that name.
Hi, any update?
Hey, I will start looking into this shortly.
Please update the version to 1.8 and reconfigure as in release notes https://github.com/tropicoo/hikvision-camera-bot/blob/master/releases/release_1.8.md
I think there will be issues but let's try.
Reopen if needed
Hello, I'm using your script, and I'm using it via an NVR, with channel number for each camera.
Everything works pretty well and solid, Except of one issue.
When I have an Alarm on Camera 1 for example, It sends me a picture + videos of all the camera that are related to the same NVR.
Is it a misconfiguration or a bug?
Thanks, and keep up the good work!