rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
365 stars 68 forks source link

Live stream not working (504 Gateway Timeout) #223

Open ajaskiewiczpl opened 1 year ago

ajaskiewiczpl commented 1 year ago

I have Dahua IP cam model IPC-HFW1431S-S4 and wanted to configure live streaming in Home Assistant using Glance card. It works without any issue when I select "auto" view (still image which refreshes every 10 seconds), but not working with the "live" option - in browser console I see 504 Gateway Timeout error for request URL: https://myhome.com/api/hls/3f139d561dbb098c6ef9c99bb828df1632ccbac2fc83bf3fb1aefe1a83dcc3fe/master_playlist.m3u8 I already added ffmpeg: to configuration.yaml and restarted Home Asisstant docker container. RTSMP port number is also properly configured. I tried master and sub stream, both don't work. What else I can check? Here is my Glance card configuration:

camera_view: live
type: picture-glance
title: Kamera 1
entities: []
camera_image: camera.dahua_cam_1_sub
iuliandro commented 1 year ago

I have a similar issue with Dahua DVR DHI-XVR5108HS-4KL. I installed the Dahua integration as per instructions and added only channel 1 (only one camera) as an integration. Now in integrations, I have 1 device with 15 entities. If I click the device I can see all the sensors working and I even see picture previews of the main stream and the two substreams.

I have ffmpeg: in the configuration.yaml file.

All great until I try to add a picture glance card on a dashboard. The Live mode shows only the first frame in the card and then is frozen. In the system log I find this error:

Logger: homeassistant.components.stream.stream.camera.homedvr_1_main Source: components/stream/init.py:428 Integration: Stream (documentation, issues) First occurred: 3:27:00 PM (11 occurrences) Last logged: 3:36:11 PM

Error from stream worker: Error opening stream (HTTP_NOT_FOUND, Server returned 404 Not Found) rtsp://username:password@192.168.X.X:554/cam/realmonitor?channel=0&subtype=0

I've tried with the main stream and both substreams with the same result regardless (subtype= changes to 0, 1, 2 in the error log)

If I switch to Auto mode instead of Live mode in the glance card properties, there are no errors in the log, but the image in the card will refresh at 10s intervals, which is not what I want.

Any ideas?

iuliandro commented 1 year ago

Error from stream worker: Error opening stream (HTTP_NOT_FOUND, Server returned 404 Not Found) rtsp://username:password@192.168.X.X:554/cam/realmonitor?channel=0&subtype=0

I solved this by defining channel=1.

I found this note in the DVR web interface:

RTSP Format rtsp://User Name:Password@IP Address:Port/cam/realmonitor?channel=1&subtype=0 channel: Channel, 1-8; subtype: Code-Stream Type, Main Stream 0, Sub Stream 1.

And it made me realize that the first channel of the DVR is 1, not 0 as I previously thought.

Now I have another strange issue, When I configure a second camera, for DVR channel=2, it shows me the channel 2 image but after the next HA restart the integration moves to channel 3 showing me the wrong video stream. Adding channel 2 again (by deleting and readding the integration) doesn't solve the issue (it shows the correct stream up untill the next HA restart). This must be a bug of some sort... This doesn't happen for channel 1. That stays the same after a restart.