starkillerOG / reolink_aio

Reolink NVR/camera API PyPI package
MIT License
65 stars 13 forks source link

Cannot take sub stream snapshot of RLC-510A #64

Closed LennartF22 closed 3 months ago

LennartF22 commented 5 months ago

Describe the bug Trying to take a sub stream snapshot of an RLC-510A produces a main stream snapshot instead.

To reproduce Create a Host object for an RLC-510A and call host.get_snapshot(0, stream='sub'). The resulting image has the same resolution as the main stream.

Expected behavior The resulting image should have the same resolution as the sub stream.

Environment:

Additional context The issue only affects my older RLC-510As, which seemingly disregard the snapType in the snapshot API call. I also have RLC-510A cameras with hardware version IPC523128M5MPV2 and firmware version v3.1.0.2368_23062700. That version of the camera properly handles the snapType parameter.

I found out that one can supply width and height parameters with the snapshot API call: https://support.reolink.com/hc/en-us/articles/360007011233-How-to-Capture-Live-JPEG-Image-of-Reolink-Cameras-via-Web-Browsers/

This actually works with both mentioned hardware versions of the RLC-510A. On top of the regular sub stream resolution (640x480) it also seems to support 896x672.

The issue could probably be resolved by supplying both the snapType and the width/height parameters to the API call. I don't know whether the resolution of the sub stream can be obtained in a nice, universal way. If there is no such way, maybe we could at least add hardcoded dimensions to the API call for the RLC-510A, as the sub stream of that camera is always 640x480. Ideally Reolink would implement the snapType parameter in a future update for that camera, but I don't think we can count on that.

user45876 commented 3 months ago

Ah, brilliant, thank you. I also fell over this here: https://github.com/home-assistant/core/issues/118617 Not only the older cameras are affected, also the relatively new Reolink Doorbell Wifi on current Firmware seems to be affected.

starkillerOG commented 3 months ago

I just added the width and heigth parameters to the snapshot call when using the sub stream. You can see the commit here: https://github.com/starkillerOG/reolink_aio/commit/d8f6263641c6e2d330fadaaa789274e635d494e9

This will make its way into homeassistant in the comming two weeks or so.

Thank you for this detailed bug report and already figuring out what the solution would be!