Closed kerryland closed 9 months ago
Correct, it is a dav file. Actually should be an encypted dav file from my understanding. I've looked around for dav -> mpg converter in the past but apart from some online utilities I'm not sure there is something already part of HA which can do the conversion. To be investigated for sure
closing for now since looks like too complicated and requiring dependencies not available by default on HA
I also tried to save the image from the url found in picurlArray
from https://open.imoulife.com/book/http/device/alarm/getAlarmMessage.html
async def download_image(session, url, filename):
async with session.get(url) as response:
if response.status == 200:
data = await response.read()
print(f"Downloaded data size: {len(data)} bytes")
# Use frombuffer instead of fromstring (handling DeprecationWarning)
img_np = np.frombuffer(data, dtype=np.uint8)
try:
# Check if data is not empty before saving with OpenCV
if np.any(img_np):
# Decode the image with OpenCV to capture correct dimensions
img = cv2.imdecode(img_np, cv2.IMREAD_UNCHANGED) # Use cv2.IMREAD_COLOR for color images
# Save with corrected dimensions
if img:
cv2.imwrite(filename, img)
print(f"Image saved: {filename}")
else:
print("image is empty in cv2")
else:
print(f"Downloaded image data is empty for {url}, skipping save.")
except Exception as e:
print(f"Error saving image: {url} ({e})")
else:
print(f"Error downloading image: {url} (status: {response.status})")
But the image that i am getting saved has width of 1 pixel and height of 35319 pixel. But when i try to use cv2.imdecode(img_np, cv2.IMREAD_UNCHANGED) as shown above, it gets cv2 decoded image as empty.
Motion-triggered callbacks contain a "picUrl" link to an image (or maybe video?), which I would love to make use of:
...but it appears to be a ".dav" file, and I can't find a way to turn that into anything useful (jpeg or png or mp4 -- anything!)
The human-detection isn't very good in the rain, so I want to send the image to deepstack for some higher quality analysis. Currently I am making a call to the generic "camera.snapshot" method, but it fires a few seconds after motion is detected, so is often too late to see anything :-(
Any ideas on how to access this image?