Amcrest PTZ functionality

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Gilley7997
Posts: 6
Joined: Sun Apr 02, 2017 5:36 pm

Re: Amcrest PTZ functionality

Post by Gilley7997 »

I took this a bit further and verified the base64 encoding of the authentication that is sent to the camera for the Basic Authentication, and that is also correct in the wireshark capture.

What I did find that was odd was the 410 authorization Failure return from the Camera appears to be processing the Authorization as a Digest Authorization rather than a Basic as the return packet from the Camera shows this:
wireshark2.png
wireshark2.png (8.24 KiB) Viewed 16731 times
I am by no means an expert on Authorization, but according to the API Documentation this type of response should only be received if a Digest Authentication was attempted.

I guess at this point I am looking to confirm with anyone else who may have been using these scripts with this Camera and is running the same Firmware as I am, or anyone else who is smarter than me that can make sense out of this.
Gilley7997
Posts: 6
Joined: Sun Apr 02, 2017 5:36 pm

Re: Amcrest PTZ functionality

Post by Gilley7997 »

Well I made a little more progress, and to me it's really looking like an issue in the firmware. I added the specific Digest Authorization Credentials to the script and I am now getting 50% success on the calls, unfortunately that means it' still garbage. This is now what my subroutine looks like:

Code: Select all

sub Right
{
    my $self = shift;
    Debug( "Move Right" );
    $self->{ua}->credentials("server:port","realm-from-wireshark","username"=>"password");
    $self->sendCmd( 'cgi-bin/ptz.cgi?action=start&code=Right&channel=0&arg1=0&arg2=1&arg3=0' );
    usleep (500);
    $self->sendCmd( 'cgi-bin/ptz.cgi?action=stop&code=Right&channel=0&arg1=0&arg2=1&arg3=0' );
}
I also removed the user credentials from the Control Address as I was specifically adding them to the script.

The Camera Moves but doesn't stop. You can see that in the logs here,
Logs.png
Logs.png (11.9 KiB) Viewed 16730 times
so actually getting a request in and accepted but not consistantly. Just doesn't make any sense.
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

Re: Amcrest PTZ functionality

Post by alabamatoy »

Amcrest has a support forum, and they do respond...
VladSI
Posts: 8
Joined: Mon May 01, 2017 9:33 pm

Re: Amcrest PTZ functionality

Post by VladSI »

Same issue with digest auth on an IP2M-841W with R17 firmware. I reverted to previous firmware version of R16 and problem solved. Found prior version via AWS S3 API calls listing their firmware directory. I can post a link if anyone needs it and doesn't know how to list S3.
VladSI
Posts: 8
Joined: Mon May 01, 2017 9:33 pm

Re: Amcrest PTZ functionality

Post by VladSI »

Home function confirmed working for IP2M-841 R16 firmware:

Code: Select all

#Move Camera to Home Position
sub presetHome
{
    my $self = shift;
#    Debug( "Home Preset" );
    $self->sendCmd( 'cgi-bin/ptz.cgi?action=start&channel=0&code=PositionABS&arg1=180&arg2=0&arg3=1&arg4=1' );
}
(Updated 20170503 - removed extra "&" in command)
Last edited by VladSI on Wed May 03, 2017 11:56 pm, edited 1 time in total.
User avatar
iconnor
Posts: 2880
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Amcrest PTZ functionality

Post by iconnor »

What's with the double & in there ?
VladSI
Posts: 8
Joined: Mon May 01, 2017 9:33 pm

Re: Amcrest PTZ functionality

Post by VladSI »

I copy and pasted the cmd line from the preset method which also had that extra "&". It works both ways but code edited regardless.
Gilley7997
Posts: 6
Joined: Sun Apr 02, 2017 5:36 pm

Re: Amcrest PTZ functionality

Post by Gilley7997 »

Can you provide the Link to the Firmware? I know that they are telling me that It is not supported but Support has been less than helpful even specifically telling me that downgrading it not supported, but they are also basically ignoring the issue.

Thanks!
VladSI
Posts: 8
Joined: Mon May 01, 2017 9:33 pm

Re: Amcrest PTZ functionality

Post by VladSI »

Gilley7997 wrote: Fri Jun 23, 2017 6:07 pm Can you provide the Link to the Firmware? I know that they are telling me that It is not supported but Support has been less than helpful even specifically telling me that downgrading it not supported, but they are also basically ignoring the issue.

Thanks!
https://s3.amazonaws.com/amcrest-files/ ... 160909.zip

This is for the IP2M-841. If you are looking for different model, let me know and I'll post the direct link for your camera.
VladSI
Posts: 8
Joined: Mon May 01, 2017 9:33 pm

Re: Amcrest PTZ functionality

Post by VladSI »

By the way - looks like R18 is out. Changelog only mentions general bug fixes. Anyone want to be the guinea pig to see if auth was fixed?
Gilley7997
Posts: 6
Joined: Sun Apr 02, 2017 5:36 pm

Re: Amcrest PTZ functionality

Post by Gilley7997 »

Actually I already did. The issue is not resolved.

There is a thread that I was participating in on the Amcrest forums as well.

Here is the link there if anyone else would like to join in.

https://amcrest.com/forum/technical-dis ... 1-s10.html
kevins7189
Posts: 1
Joined: Tue Sep 26, 2017 1:01 am

Re: Amcrest PTZ functionality

Post by kevins7189 »

Hi, new to zoneminder.
Using IP2-841, with R16 firmware. Zm v1.30.4
I am trying to use PTZ, I use Fedora, so the control script is in /usr/share/perl5/vendor_perl/Zoneminder/Control.
Got the control added, restarted zm, but when I send a command, I get
Invalid control parameter: Right /usr/share/zoneminder/www/includes/control_functions.php 282
Camera control command FAILED: '500 No Host option provided' for URL /cgi-bin/ptz.cgi?action=stop&code=Right&channel=0&arg1=0&arg2=1&arg3=0 zmcontrol.pl

What is that trying to tell me?
VladSI
Posts: 8
Joined: Mon May 01, 2017 9:33 pm

Re: Amcrest PTZ functionality

Post by VladSI »

Did you fill out the "Control Address" box in the "Control" configuration panel? The URL is incomplete as it does not have the auth and host. It should look like "user:password@host/cgi-bin/ptx.cgi.....".
fiddletwix
Posts: 1
Joined: Sat Jan 20, 2018 8:28 am

Re: Amcrest PTZ functionality

Post by fiddletwix »

I just bought an Amcrest camera and was excited to use this control script. I was disappointed that it didn't work and read just the first page of this thread to find someone else had the same issue but I didn't read the 2nd page where they figured out the digest authentication being the issue. So I spent a few hours figuring out the cause of the 401 error (I should have read the 2nd page) and rewriting the script to handle this method of authentication. This is working for this firmware: 2.420.AC00.18.R, Build Date: 2017-05-21 I want to do a little cleanup of code and will post the script here.
simonlok
Posts: 3
Joined: Fri Feb 23, 2018 1:05 pm

Re: Amcrest PTZ functionality

Post by simonlok »

Would you be willing to share your script?

I am intersted in making the control work for my Amcrest cameras.
Post Reply