How can I set date and time in a hikvision camera from linux command line? Or from some language, like Python, PHP, etc... I have a computer connected to cameras, and I want to change date and time in cameras without access to browser, only from terminal. Thanks
-
Could you use curl? – JoshMc Jun 18 '19 at 05:44
-
Yes, I can use curl. – Rui Martins Jun 18 '19 at 23:41
2 Answers
You might use the document HIKVISION ISAPI . as you know, interface depends on camera firmware version. For setting date and time for camera. you needs HTTP PUT method with URL
http://hikvision_camera_ipaddress[:http_port]/ISAPI/System/time.
On general, An IP camera has 3 types of time mode; NTP, manual, sync(timecorrect for HIKVISION).
It would be better for getting date and time of the camera through GET method first with the same above url. After that you will get a hint for HTTP body for setting date and time via PUT method.
For more detail you could refer the document 8.1.9

- 492
- 7
- 15
If your camera supports onvif you can use python library called python-onvif (for 2.x):
pip install onvif
or python-zeep-onvif(for 3+):
pip3 install --upgrade onvif_zeep
Python code:
from onvif import ONVIFCamera
camera_ip = "your camera ip"
camera_port = "your camera port, default is 80"
wsdl_path = "path to wsdl folder"
cam = ONVIFCamera(args.ip, 80, login, password, wsdl_path)
time_request = cam.devicemgmt.create_type('SetSystemDateAndTime')
time_request.DateTimeType = "Manual"
time_request.DaylightSavings = True
time_request.UTCDateTime.Time.Hour = 4
time_request.UTCDateTime.Time.Minutes = 20
time_request.UTCDateTime.Time.Seconds = 0
cam.devicemgmt.SetSystemDateAndTime(time_request)
Please, check python-onvif package page and onvif operation page for more detailed info

- 145
- 5