Open Moortiii opened 3 years ago
I inspected the connection attempt using Wireshark and discovered that it returns a 401 Unauthorized
for an initial request towards /cgi-bin/magicBox.cgi?action=getMachineName
. I can also confirm that connecting via the IP address directly in the browser allows me to see the camera stream in real-time using the same credentials as provided to python-amcrest.
I see the same problem. I'm using the current version of python-amcrest with up-to-date Amcrest firmware. The camera works fine with a web browser, vlc, and Amcrest View software. It doesn't work with python-amcrest.
Note: I'm passing keyword args to camera.snapshot() to confirm to the current code which expects keyword arguments only.
>>> camera = AmcrestCamera('10.5.5.17', 80, <USERNAME>, <PASSWORD>).camera
>>> print("Information:", camera.software_information)
Information: ('2.820.00AC002.0.R', '2023-04-08\r\n')
>>> print("Video enabled:", camera.video_enabled)
Video enabled: True
>>> camera.snapshot(channel=0, path_file="/Users/jps/Desktop/snapshot00.jpeg")
<AMC06592CCA1190F65:AMC06592CCA1190F65> Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http://10.5.5.17:80/cgi-bin/snapshot.cgi?channel=0')
<AMC06592CCA1190F65:AMC06592CCA1190F65> Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http://10.5.5.17:80/cgi-bin/snapshot.cgi?channel=0')
<AMC06592CCA1190F65:AMC06592CCA1190F65> Trying again due to error: HTTPError('400 Client Error: Bad Request for url: http://10.5.5.17:80/cgi-bin/snapshot.cgi?channel=0')
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/amcrest/http.py", line 286, in _command
resp.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://10.5.5.17:80/cgi-bin/snapshot.cgi?channel=0
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.11/site-packages/amcrest/snapshot.py", line 84, in snapshot
ret = self.command(cmd, timeout_cmd=timeout, stream=stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/amcrest/http.py", line 222, in command
return self._command(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/amcrest/http.py", line 295, in _command
raise CommError(error) from error
amcrest.exceptions.CommError: 400 Client Error: Bad Request for url: http://10.5.5.17:80/cgi-bin/snapshot.cgi?channel=0
I'm trying to stream a realtime recording from an Amcrest IP4M camera via Wifi. The camera connects just fine, and can be controlled and take snapshots. When I try to connect using realtime_stream, the HTTP API throws
400 Client Error: Bad Request for url: http://192.168.1.173:80/cgi-bin/realmonitor.cgi?action=getStream&channel=1&subtype=0
.I have tried changing the channel and sub-type accordingly, referencing the HTTP API Docs.
Minimal example:
Output:
Traceback: