Scripting Amcrest NVR to adjust physical monitor

Posted on
Thu Apr 16, 2020 8:42 am
whmoorejr offline
User avatar
Posts: 763
Joined: Jan 15, 2013
Location: Houston, TX

Scripting Amcrest NVR to adjust physical monitor

I figured out how to script the Amcrest NVR to change the layout of the physical monitor attached to it. May work with other NVRs?

Short story: My end-goal is to figure out the least expensive way to put a CCTV camera image on a TV screen. After trying the RTSP route, I wan't happy with the delay in pulling a camera image. My attempt now is to route the HDMI from the NVR to a TV. One option would be to use a HDMI -> HDTV encoder which would put the NVR on all TVs via COAX or via HDHomerun. Option 2 would be to use the BlackMagic ATEM Mini to have multiple HDMI sources run directly into the indigo Mac and stream out via RemoteSight or SecuritySpy. #2 sounds really fun and cheeper than the encoder option, but will have the same RTSP streaming lag issue that got me here.

Step 1: Figure out which channel, mode and group to use: (I did this experimenting on google chrome browser before putting in as a script on Indigo)

Note: I'm not sure if I was running into a max-user thing on the NVR. (versus a camera, an NVR may only allow a user to access the NVR in one instance only.). So, on the NVR, I created a "Indigo" account with it's own password)

Format from API:
Code: Select all
http://<server>/cgi-bin/split.cgi?action=getMode&channel=<ChannelNo>

example from API:
Code: Select all
http://192.168.1.108/cgi-bin/split.cgi?action=getMode&channel=1

What worked for me:
Code: Select all
http://user:password@192.168.1.108:8018/cgi-bin/split.cgi?action=getMode&channel=0


When I tried "channel=1" I got an error. When I tried "channel=0", it returned information.... a list of channel, modes and groups.

Now the command to change the screen...
What worked for me (Single camera on the monitor):
Code: Select all
http://user:password@192.168.1.101:8101/cgi-bin/split.cgi?action=setMode&channel=0&mode=split1&group=0

What worked for me (8 cameras on the monitor with 1 large camera image)
Code: Select all
http://user:password@192.168.1.101:8101/cgi-bin/split.cgi?action=setMode&channel=0&mode=split8&group=0

For me, channel is always "0". "split1" is a single channel on the screen. "group=0" is camera #1 on the NVR. (Camera # on the NVR -1 = group #)
"split8" is the 8 camera view with 7 small windows and one larger window. The larger window in the above is Camera #1 on the NVR, "group=0"

So, if there is motion at my driveway, I can "mode=split8&group4" which will bring up the 8 camera view with camera #5 (my driveway camera) as the big camera image.

For a 4-way split.... if you have 16 cameras, group=0 will be the first 4 cameras. group=3 will be cameras 13,14,15,16 on a 4-way split.

Once you figure out what commands are working with your NVR, now it's time to make the action commands to control. I have an 8 channel NVR that I'm setting up for this, so I created 16 actions. One action for each split1 per camera. One action for each split8 with a focus on each camera.

This is what I put in an action with a python script (changing the mode and group for each action).
Code: Select all
import requests
url = 'http://user:password@192.168.1.101:8101/cgi-bin/split.cgi?action=setMode&channel=0&mode=split1&group=0'
reply = requests.get(url)
reply.raise_for_status()

I hope others find this helpful.

Bill
My Plugin: My People

Posted on
Fri Apr 17, 2020 5:30 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Scripting Amcrest NVR to adjust physical monitor

Neat. Thanks for sharing your hack.

Note that using Basic Auth in a 'http://' URL (username:password@...) sends the credentials as clear text. This may not be an issue for you since you're running this entirely on the LAN (at least I assume you are). If you use 'https://' instead, it would add a bit more security. However, IIRC, if using 'https://' you'll need to url encode special characters in the username and password fields.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Apr 17, 2020 7:59 am
whmoorejr offline
User avatar
Posts: 763
Joined: Jan 15, 2013
Location: Houston, TX

Re: Scripting Amcrest NVR to adjust physical monitor

Correct, internal on the LAN. Maybe it's because it's an older Amcrest NVR? All my newer cameras require digest authentication to manipulate (like to pull a snapshot image)

Code: Select all
   from requests.auth import HTTPDigestAuth
   reply = requests.get(IMAGE_URL,
      auth=HTTPDigestAuth(USER_NAME, USER_PASSWORD),
      timeout = 2.0)
   reply.raise_for_status()   

Bill
My Plugin: My People

Posted on
Fri Apr 17, 2020 11:01 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Scripting Amcrest NVR to adjust physical monitor

DaveL17 wrote:
Note that using Basic Auth in a 'http://' URL (username:password@...) sends the credentials as clear text.


Actually, they're not clear text. They're base64 encoded. Which is not encrypted, so it's not secure. I know, I'm being pedantic.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Apr 17, 2020 11:08 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Scripting Amcrest NVR to adjust physical monitor

There's nothing at all wrong with accuracy. Especially when it comes to security.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 11 guests