Release Surveillance Room - Your IP Camera Companion with extra Foscam HD Support
Amcrest owners, I wish that I knew python, because I'd be able to contribute a proper, non-generic camera type for amcrest cams to this project.  But sadly, I can only script the hell out of bash, not python.  But perhaps someone who can script python (or maybe even Maikito26 if we ask nicely enough) can take this information and run with it, because as part of rolling my own alexa integration for my amcrest cams, I've found some useful things. 

In recent firmwares, Amcrest's API only responds to HTTP Digest auth.  For example, the command
curl "http://<username>:<password>@<camera ip>:80/cgi-bin/snapshot.cgi?1 

used to return just fine.  Now, you'd have to do 'curl --digest' in order to gain access.  Previous api specifications allowed encoding username and password as &usr=<user>&pwd=<password>, but now you can only pass them as a URL prefix:  http://<username>:<password>@<camera ip>

The correct URLs for returning a snap, rtsp, or mjpg are definitely the below, but without class urllib.request.HTTPDigestAuthHandler() extending urllib in the python scripts, only RTSP can be accessed properly in this addon - that's why people are seeing black screens for previews/multicams.

Snapshot:           http://<USER>:<PASSWORD>@<CAMERA_IP>/cgi-bin/snapshot.cgi?1
Video Stream :     rtsp://<USER>:<PASSWORD>@<CAMERA_IP>:554/cam/realmonitor?channel=1&subtype=0
MJPEG:               http://<USER>:<PASSWORD>@<CAMERA_IP>/cgi-bin/mjpg/video.cgi?channel=1&subtype=1

To get motion alarms working, the api calls to show the status of the alarm (is it currently triggered or not) is 
http://<USER>:<PASSWORD>@<CAMERA_IP>/cgi-bin/alarm.cgi?action=getOutSlots

Foscam returns XML to API calls, whereas Amcrest just returns a string - in the case of the alarm state above, that would be 
result=0    or   result=1

where 0 means not in alarm state, and 1 means alarm has been triggered.  So while the python script for the foscam HD cameras uses 'xml.etree.ElementTree' to parse the API response, getting the status code for the Amcrests would have to use something like raw_string.split("=", 2)   (but again, I don't really python, I can just read it and mildly edit some, so that's probably not the best way to do it.)

Maikito26's implementation for the Foscam API is incredibly full featured, with the ability to fetch and set nearly every setting and state the foscam cameras have.  But if someone did say a file /resources/lib/ipcam_api_amcrest.py  that implemented the http digest tweak for urllib in order to properly fetch MPJG steams and snapshots, and just the get alarm state api call, then we'd have most of the core awesomeness of the surveillance rooms addon available for Amcrest cams, without having to implement the whole range of API commands.
Reply


Messages In This Thread
All Cameras - by zaxcom - 2016-08-25, 03:17
Axis M211 - by OnkelKraecker - 2017-03-08, 13:36
RE: Axis M211 - by jinux - 2017-03-08, 14:43
Axis M 211 - by OnkelKraecker - 2017-10-13, 12:57
RE: Axis M 211 - by maikito26 - 2018-01-24, 15:00
RE: Surveillance Room - Your IP Camera Companion with extra Foscam HD Support - by thestig - 2018-04-07, 22:25


Logout Mark Read Team Forum Stats Members Help
Surveillance Room - Your IP Camera Companion with extra Foscam HD Support7
This forum uses Lukasz Tkacz MyBB addons.