tchellomello / python-amcrest

A Python 2.7/3.x module for Amcrest and Dahua Cameras using the SDK HTTP API.
GNU General Public License v2.0
216 stars 76 forks source link

Cannot access realtime_stream in cv2 python #115

Closed lamachine closed 5 years ago

lamachine commented 5 years ago

I can see the channel 1 (low res mpeg) stream, control the camera movement, but cannot use the high-rest stream due to access problems.

camera1 = amcrest.AmcrestCamera('192.168.1.xxx', 80 'admin', 'pswd', ).camera

vs = VideoStream(camera1.realtime_stream(
    channel=0, typeno=None, path_file=None`)).start

frame = vs.read()
cv2.imshow("Frame", frame)

The result is Trying again due to error 401 Client Error: Unauthorized for url: http://192.168.1.35:80/cgi-bin/realmonitor.cgi?action=getStream&channel=0&subtype=None

omerdn1 commented 5 years ago

looking at their API PDF, page 2: https://s3.amazonaws.com/amcrest-files/Amcrest+HTTP+API+3.2017.pdf

I see they've removed the API documentation for "getting real stream and playback stream APIs". I think this might be the reason you're receiving this error. I guess they had to block these endpoints due to security implications :/ maybe we can get a confirmation from the author.

lamachine commented 5 years ago

I saw that... but in the spirit of "if you can't open it, you don't own it" I am working my way through their tech support.  I will update my post if I resolve it.  Thanks!  -- Bob O  On Tuesday, May 7, 2019, 10:18:27 AM PDT, omerdn1 notifications@github.com wrote:

looking at their API PDF, page 2: https://s3.amazonaws.com/amcrest-files/Amcrest+HTTP+API+3.2017.pdf

I see they've removed the API documentation for "getting real stream and playback stream APIs". I think this might be the reason you're receiving this error. I guess they had to block these endpoints due to security implications :/ maybe we can get a confirmation from the author.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

tchellomello commented 5 years ago

Hello @omerdn1 and @lamachine, thanks for raising this issue. Yes, unfortunately, it this is not in the API anymore, there is nothing we can do. Good luck @lamachine and please keep us posted!

lamachine commented 5 years ago

Finally got a resolution... It was actually to use the information about the RTSP stream in the API, but I kept missing bits and pieces.

CV2 can open an RTSP stream directly.

rtsp://[username]:[password]@[camera IP]:554/cam/realmonitor?channel=1&subtype=0

The channel is always 1, and subtype 0 is the main stream (described as type in API doc). The port defaults to 544 but can be confirmed by the following http://[camera IP]/cgi-bin/configManager.cgi?action=getConfig&name=RTSP