Turning camera on-off (and other command) with http command, possible?

klauscla

n3wb
Joined
Apr 17, 2018
Messages
14
Reaction score
0
Hi, I am not a programmer, so pardon me if I use not the correct terminology.

I wish to control some function of my Hikvision cams through http, for example in another forum for other cameras they turn on camera motion detection sending this command from a linux machine
"/usr/bin/curl --basic --user username:password GET 'http://camera_ip/adm/set_group.cgi?group=EVENT&event_trigger=1'"

and this for turning off
"/usr/bin/curl --basic --user username:password GET 'http://camera_ip/adm/set_group.cgi?group=EVENT&event_trigger=0'"

I wanted to do the same for my Hikvision cameras and the following commands
Line Crossing Detection ON OFF
Motion Detection ON OFF
Camera ON OFF (start or stop streaming)
Recording ON OFF


Are the above commands available?
 

StewartM

Getting the hang of it
Joined
Dec 11, 2017
Messages
260
Reaction score
75
Location
Cape Town
Yes, some of the commands you are looking for are available. You will have to do some digging to get the others working.
I'm using curl for Windowsin this example.
First, make sure you have WEB Authentication set to digest/basic on the camera.
upload_2019-5-24_13-47-16.png
Extract the curl.zip file you downloaded to C:\curl
Open a command prompt and navigate to the curl folder.
Line Crossing:
Create a xml file in the curl folder called lineCrossing_off.xml with the following in the body (amend the id to the camera's):
<LineDetection>
<id>1</id>
<enabled>false</enabled>
</LineDetection>

Amend and run the following:
curl -T lineCrossing_off.xml upload_2019-5-24_14-0-57.png

Motion Detection:
As before, create a xml file in the curl folder called motionDetection_off.xml
<MotionDetection xmlns="" version="2.0">
<enabled>false</enabled>
<MotionDetectionLayout version="2.0">
</MotionDetectionLayout>
</MotionDetection>

Amend and run the following:
curl -T motionDetection_off.xml upload_2019-5-24_14-10-43.png

You can create the similar xml files to enable the features much the same way. This should get you started. Keep us posted.
 

klauscla

n3wb
Joined
Apr 17, 2018
Messages
14
Reaction score
0
Ye
You can create the similar xml files to enable the features much the same way. This should get you started. Keep us posted.

Fantastic, thanks a lot.

The one Camera ON OFF, you think its possible technically? Because I do not see a correspoding action in webui (while there is Line crossing, and Motion detection, in webui )?
 

StewartM

Getting the hang of it
Joined
Dec 11, 2017
Messages
260
Reaction score
75
Location
Cape Town
If you mean stop the live streaming, yes it's possible. You could disable RTSP to stop the streaming then re-enable it. One really needs to research a better way to do this BUT... let's give it a go.
Same as before:
curl -T disableRTSP.xml http://admin:xxx@192.168.1.xx/ISAPI/Security/adminAccesses
Body of disableRTSP.xml
<AdminAccessProtocolList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<AdminAccessProtocol version="2.0">
<AdminAccessProtocol version="2.0">
<id>4</id>
<enabled>false</enabled>
<protocol>RTSP</protocol>
<portNo>554</portNo>
</AdminAccessProtocol>
</AdminAccessProtocol>
</AdminAccessProtocolList>
upload_2019-5-24_15-42-17.png

And..
upload_2019-5-24_15-43-8.png
 

klauscla

n3wb
Joined
Apr 17, 2018
Messages
14
Reaction score
0
Wow, thanks a lot, will implement immediately. Trying to find the camera ID, since I am connecting to each camera directly, maybe the ID is always 1??

I guess for enabling need to change it too

<enabled>true</enabled>
 
Last edited:

StewartM

Getting the hang of it
Joined
Dec 11, 2017
Messages
260
Reaction score
75
Location
Cape Town
If you connect directly to a camera the ID is always 1. 101 for the main stream settings, 102 for the sub-stream.
Correct on <enabled>true</enabled>
 

StewartM

Getting the hang of it
Joined
Dec 11, 2017
Messages
260
Reaction score
75
Location
Cape Town
Let me know if you get it working. The next step would be to create a batch file to make the changes less of a chore.
 

klauscla

n3wb
Joined
Apr 17, 2018
Messages
14
Reaction score
0
Let me know if you get it working. The next step would be to create a batch file to make the changes less of a chore.
Hi, perfectly working for RTSP, thjanks a lot!!

Do you know how to block also the image? I currently use these command to retrieve data from the camera, so I need to block also the picture

still_image_url: http://admin:xxxxx@192.168.1.4/ISAPI/Streaming/channels/101/picture
show_stream: rtsp://admin:xxxxx@192.168.1.4:554/ch1/main/av_stream
 

StewartM

Getting the hang of it
Joined
Dec 11, 2017
Messages
260
Reaction score
75
Location
Cape Town
Not sure. It might be possible to force the still image to no format voiding the request. Are you trying to block the still image for admin, a specific user or for everyone? Same for RTSP, if you are the only one with the admin login, who are you trying to block? What is your ideal setup?
 

klauscla

n3wb
Joined
Apr 17, 2018
Messages
14
Reaction score
0
Not sure. It might be possible to force the still image to no format voiding the request. Are you trying to block the still image for admin, a specific user or for everyone? Same for RTSP, if you are the only one with the admin login, who are you trying to block? What is your ideal setup?
I use the stream in a Home Assistant, which gets the stream with the two commands above (an rtsp and image jpg).

Ideally, for privacy concern, I wish to disable the cameras entirely (so that no program can watch the feed): blocking RTSP is great, but need to block that JPG too

Currently I use only one user: admin, but the feed go to Tinycam and Home Assistant
 
Joined
Jul 18, 2019
Messages
9
Reaction score
0
Location
Munchen, Germany
Yes, some of the commands you are looking for are available. You will have to do some digging to get the others working.
I'm using curl for Windowsin this example.
First, make sure you have WEB Authentication set to digest/basic on the camera.
View attachment 42662
Extract the curl.zip file you downloaded to C:\curl
Open a command prompt and navigate to the curl folder.
Line Crossing:
Create a xml file in the curl folder called lineCrossing_off.xml with the following in the body (amend the id to the camera's):
<LineDetection>
<id>1</id>
<enabled>false</enabled>
</LineDetection>


Amend and run the following:
curl -T lineCrossing_off.xml View attachment 42664

Motion Detection:
As before, create a xml file in the curl folder called motionDetection_off.xml
<MotionDetection xmlns="" version="2.0">
<enabled>false</enabled>
<MotionDetectionLayout version="2.0">
</MotionDetectionLayout>
</MotionDetection>


Amend and run the following:
curl -T motionDetection_off.xml View attachment 42665

You can create the similar xml files to enable the features much the same way. This should get you started. Keep us posted.
I'm trying to set my web authentication to "digest/basic", but it only allows "digest". On my other cameras I even cannot find this setting.
By setting it to "digest" i get "Document Error: Unauthorized" in Curl.
Is there a way to solve this...or are my cameras too old?
 
Top