Hikvision PTZ control

Post here to ask any questions about hardware suitability, configuration in ZoneMinder, or experiences. If you just want to know if something works with ZoneMinder or not, please check the Hardware Compatibility sections in the forum, and the Wiki first. Also search this topic as well.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Hikvision PTZ control

Post by iamnotme »

I've returned to Zoneminder after playing about with it previously but not implementing it. I am using the master ppa so I am on 1.37.47

I did manage to get the Hikvision PTZ control working last time, albeit slowly, for my camera DS-2DE5425IW-AE. However I've tried again this morning and whenever I try and move the camera I get a 500 Internal Server Error from zmcontrol.

Anything obvious I may be missing?
User avatar
iconnor
Posts: 2904
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Hikvision PTZ control

Post by iconnor »

Turn on debugging and restart. There will e more info in the logs. zmcontrol doesn't do 500's so i assue it is reporting a 500 from the camera. Which means it doesn't like what we are sending.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Re: Hikvision PTZ control

Post by iamnotme »

It's taken a while to get back to. I couldn't get the debug log to save where I wanted or even generate.

I put _zmc_m1 | _zmcontrol_1 in the devices to log, and /home/jon/zmc_m1_ptz.log as my log file but nothing appears even after several restarts.
Attachments
Screenshot_20231222_122541.png
Screenshot_20231222_122541.png (82.82 KiB) Viewed 9846 times
User avatar
iconnor
Posts: 2904
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Hikvision PTZ control

Post by iconnor »

It won't have permission to write to your home directory.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Re: Hikvision PTZ control

Post by iamnotme »

It wouldn't write to /var/log either so I tried /var/log/zm and still no logging output to a dedicated file as specified.
SonopaalFounik
Posts: 4
Joined: Sat Oct 28, 2023 11:41 am

Re: Hikvision PTZ control

Post by SonopaalFounik »

I'm here to help you troubleshoot the 500 Internal Server Error with Hikvision PTZ control in Zoneminder 1.37.47. Here are some steps to investigate:

1. Check Logs:

Zoneminder Logs: Carefully review Zoneminder's logs (often in /var/log/zm) for specific error messages or clues related to PTZ control or Hikvision communication.
Web Server Logs: If Zoneminder uses Apache or Nginx, examine their logs for additional insights into server-side errors.
2. Verify Camera Connectivity:

Network Access: Ping the camera's IP address to ensure network connectivity.
Credentials: Double-check that you're using the correct username and password for PTZ control in Zoneminder's configuration.
Firmware Updates: Consider updating the camera's firmware to the latest version for compatibility and bug fixes.
3. Inspect Configuration:

Hikvision Protocol: Ensure you've selected the correct Hikvision protocol (e.g., "Hikvision-CGI") in Zoneminder's camera configuration.
Port Number: Verify that the port number for PTZ control matches the camera's settings.
User Permissions: Confirm that the user running Zoneminder has the necessary permissions to access camera controls.
4. Test Manually:

zmcontrol: Attempt to control the camera directly using the zmcontrol command-line tool to isolate issues with the web interface.
5. Permissions and File Integrity:

Check Permissions: Ensure Zoneminder has appropriate permissions to access files and directories related to PTZ control.
Verify File Integrity: Use tools like md5sum or sha1sum to check the integrity of Zoneminder files, especially those involved in PTZ functionality.
6. Browser Compatibility:

Try Different Browsers: Test PTZ control in different web browsers to rule out browser-specific issues.
Disable Extensions: Temporarily disable browser extensions that might interfere with web requests.
7. Server Resource Availability:

Check Resource Usage: Ensure your server has sufficient resources (CPU, RAM) to handle PTZ operations smoothly.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Re: Hikvision PTZ control

Post by iamnotme »

I'm back on this after a few months away. I kind of gave up on it to be honest, but I'm still determined to get a solution that doesn't rely on HikVision to access cameras remotely.

I have had a look at a few things in the logs. I could see there was an error being generated in the zmdc.log because I hadn't filled out the Auto Stop Timeout and Tracking Delay, so I've cleared that up.

In zmcontrol_1.log when running

Code: Select all

perl -T zmcontrol.pl --id=1 --command=MoveConLeft
I worked this out from looking at the HikVision.pm file. The command line returns with no message but in the zmcontrol_1.log I get an error

Code: Select all

03/02/24 16:12:42.098279 zmcontrol_1[250891].ERR [ZoneMinder::Control:170] [Can't access name:MoveConDown AUTOLOAD:ZoneMinder::Control::HikVision::MoveConDown member of object of class ZoneMinder::Control::HikVision from main:171]
The frustrating thing is I know that controls through ONVIF work as Frigate could control the camera this morning when I was looking at that and I have had it working before with iSpy.

It's great when someone tells you to check file permissions without specifying what they should be. The camera streams fine, and I used the same credentials this afternoon as I did with Frigate this morning.

When I do a simple move using the on screen controls this is what I get

Code: Select all

03/02/24 16:22:56.977994 zmcontrol_1[250891].INF [main:121] [Received TERM, exiting]
03/02/24 16:22:57.025997 zmcontrol_1[250891].INF [main:191] [Control server 1/HikVision exiting]
03/02/24 16:22:58.002958 zmcontrol_1[282507].INF [main:116] [Starting control server 1/HikVision]
03/02/24 16:22:58.037420 zmcontrol_1[282507].INF [main:127] [Control server 1/HikVision starting at 24/03/02 16:22:58]
03/02/24 16:23:07.998573 zmcontrol_1[282507].ERR [ZoneMinder::Control::HikVision:255] [500 Internal Server Error]
mikb
Posts: 604
Joined: Mon Mar 25, 2013 12:34 pm

Re: Hikvision PTZ control

Post by mikb »

iamnotme wrote: Sat Mar 02, 2024 4:25 pm It's great when someone tells you to check file permissions without specifying what they should be.
... and this is why it's not particularly useful having people feeding AI/bot generated content into the forum. The post you refer to seems to come from a bot account. Unless they wish to post to confirm that it's just their posting style -- I could be wrong.
User avatar
iconnor
Posts: 2904
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Hikvision PTZ control

Post by iconnor »

Let's turn on debug so that it logs what it sends. The Internal Server Error is what the camera is sending back, so we must be sending something invalid.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Re: Hikvision PTZ control

Post by iamnotme »

I turned on debug logging with it set to level 9 and added zmc_m1 and zmcontrol as the target. These are the outputs:

zmc_m1

Code: Select all

03/03/24 09:23:58.135101 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 200 - Capturing at 8.00 fps, capturing bandwidth 343547bytes/sec Analysing at 0.00 fps]
03/03/24 09:24:10.587786 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 300 - Capturing at 8.03 fps, capturing bandwidth 323058bytes/sec Analysing at 0.00 fps]
03/03/24 09:24:23.102943 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 400 - Capturing at 7.99 fps, capturing bandwidth 342351bytes/sec Analysing at 0.00 fps]
03/03/24 09:24:35.552241 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 500 - Capturing at 8.03 fps, capturing bandwidth 321927bytes/sec Analysing at 0.00 fps]
03/03/24 09:24:48.051576 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 600 - Capturing at 8.00 fps, capturing bandwidth 342857bytes/sec Analysing at 0.00 fps]
03/03/24 09:25:00.510470 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 700 - Capturing at 8.03 fps, capturing bandwidth 322160bytes/sec Analysing at 0.00 fps]
03/03/24 09:25:13.016608 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 800 - Capturing at 8.00 fps, capturing bandwidth 342400bytes/sec Analysing at 0.00 fps]
03/03/24 09:25:25.465870 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 900 - Capturing at 8.03 fps, capturing bandwidth 321427bytes/sec Analysing at 0.00 fps]
03/03/24 09:25:37.962122 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1000 - Capturing at 8.00 fps, capturing bandwidth 342910bytes/sec Analysing at 0.00 fps]
03/03/24 09:25:50.430901 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1100 - Capturing at 8.02 fps, capturing bandwidth 321449bytes/sec Analysing at 0.00 fps]
03/03/24 09:26:02.927582 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1200 - Capturing at 8.00 fps, capturing bandwidth 342990bytes/sec Analysing at 0.00 fps]
03/03/24 09:26:15.386027 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1300 - Capturing at 8.03 fps, capturing bandwidth 323897bytes/sec Analysing at 0.00 fps]
03/03/24 09:26:27.889618 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1400 - Capturing at 8.00 fps, capturing bandwidth 343913bytes/sec Analysing at 0.00 fps]
03/03/24 09:26:40.337874 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1500 - Capturing at 8.03 fps, capturing bandwidth 322096bytes/sec Analysing at 0.00 fps]
03/03/24 09:26:52.845150 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1600 - Capturing at 8.00 fps, capturing bandwidth 342363bytes/sec Analysing at 0.00 fps]
03/03/24 09:27:05.313978 zmc_m1[2030971].INF-zm_monitor.cpp/1832 [Drive: 1700 - Capturing at 8.02 fps, capturing bandwidth 322268bytes/sec Analysing at 0.00 fps]
zmcontrol_1

Code: Select all

03/03/24 09:22:43.303136 zmcontrol_1[293738].INF [ZoneMinder::Control::HikVision:245] [Check username/password is correct]
03/03/24 09:22:43.335915 zmcontrol_1[293738].ERR [ZoneMinder::Control::HikVision:253] [401 Unauthorized]
03/03/24 09:22:44.282396 zmcontrol_1[293738].INF [ZoneMinder::Control::HikVision:245] [Check username/password is correct]
03/03/24 09:22:44.321987 zmcontrol_1[293738].ERR [ZoneMinder::Control::HikVision:253] [401 Unauthorized]
03/03/24 09:23:29.039502 zmcontrol_1[293738].INF [main:121] [Received TERM, exiting]
03/03/24 09:23:29.071425 zmcontrol_1[293738].INF [main:191] [Control server 1/HikVision exiting]
03/03/24 09:23:30.056770 zmcontrol_1[2030993].INF [main:116] [Starting control server 1/HikVision]
03/03/24 09:23:30.090514 zmcontrol_1[2030993].INF [main:127] [Control server 1/HikVision starting at 24/03/03 09:23:30]
03/03/24 09:23:57.119316 zmcontrol_1[2030993].ERR [ZoneMinder::Control::HikVision:255] [500 Internal Server Error]
03/03/24 09:23:57.809872 zmcontrol_1[2030993].ERR [ZoneMinder::Control::HikVision:255] [500 Internal Server Error]
03/03/24 09:24:01.643305 zmcontrol_1[2030993].ERR [ZoneMinder::Control::HikVision:255] [500 Internal Server Error]
03/03/24 09:24:02.711448 zmcontrol_1[2030993].ERR [ZoneMinder::Control::HikVision:255] [500 Internal Server Error]
03/03/24 09:24:44.536723 zmcontrol_1[2030993].ERR [ZoneMinder::Control:170] [Can't access name:MoveConLeft AUTOLOAD:ZoneMinder::Control::HikVision::MoveConLeft member of object of class ZoneMinder::Control::HikVision from main:171]
The authentication issue is because I was messing around trying different users yesterday, and put the wrong password in when I set it back to what it should be. I'm not sure if there is anything else that you need.
User avatar
iconnor
Posts: 2904
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Hikvision PTZ control

Post by iconnor »

Those are not debug logs. Don't need zmc. Just zm_control will do.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Re: Hikvision PTZ control

Post by iamnotme »

Debug was on, and set to level 9, this was the only output I got even though I specified a separate file. I’m away on a course now until Friday so I’ll have a go again when I’m back.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Re: Hikvision PTZ control

Post by iamnotme »

Ok, I am home and back looking at this. I have logging set as the image, but I don't get an output file. Are my logging settings ok, and are there any other components I should be logging? Since I took the image I have added _zmcontrol to the debug targets but still no joy
Attachments
zoneminder_logging.png
zoneminder_logging.png (83.87 KiB) Viewed 3111 times
User avatar
iconnor
Posts: 2904
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Hikvision PTZ control

Post by iconnor »

You do need to restart after changing logging settings.
iamnotme
Posts: 22
Joined: Mon Aug 29, 2022 9:21 am

Re: Hikvision PTZ control

Post by iamnotme »

I restarted several times using the button on the top right of the web page before attempting to get debug output, should it be done directly on the systemd service?
Post Reply