Just comment it out. opencv/mpeg will detect the formats. This is only to force a specific decoder.
Ok thanks.
Iād love to know how you get on with this. I have the same setup and use Frigate (as Iām aware you do) to display the live camera feeds from that. Doing this directly in HA would reduce the 10+ second delay on the frontend without involving Frigate, and make everything much smoother!
So far it didnāt change anything when put into custom_components. I guess Iāll dive into the container and try to change it there and see if thereās any difference.
So when I replace the file in the container and check the config I get:
Platform error camera.ffmpeg - No module named 'cv2'
I did install opencv-python on the host OS, in the hopes it would be inherited by the container, but that doesnāt seem to have happened.
Yeah thatās an illustration as to why I donāt use containers for applications like Home Assistantā¦ When you have so many components with dependencies and the program is as large and variable as it is, it just makes no sense to me. It seems like you will need to find a way to get it installed in the container. Maybe try creating a dummy opencv component in your setup which will force the dependency download?
That was a good idea, adding
image_processing:
- platform: opencv
to my configuration.yaml got rid of the errorā¦ Unfortunately even after that, the camera delay is no betterā¦ Itās actually a bit worse. I wonder if it has something to do with GPU use?
Out of curiosity, could you describe what kind of hardware you are using and what kind of latency you get when compared to the live action to when you see the update on the video? Iād be willing to add GPU if I thought it could address the latency issues. Thanks for trying to help out with my issues.
I have 0 latency. I am running all this on a ubuntu VM using a single thread (half a core) of an i7 6700K with a bunch of other programs related to home automation. I did bridge in an RTX2070 for programs in the VM to run a bunch of video inferencesā¦
This may no provide any value, but I have a dumb simple little Swann (hikvision) 8 cam system. TVI cams over coax to network attached DVR - super simple consumer grade stuff. Iām using the hikvision integration to grab the streams over rstp. I have one stream set to preload, and have it on my default Lovelace view. That stream seems to load almost instantly and has just about no lag. The experience is just about comparable to accessing the streams via the Swann app.
I tried using the onvif integration and had a poor experience compared to the hikvision route. Much like what you guys are describing.
Not sure if this helps, but wanted to share my positive experiences streaming over that integration. Iām running vanilla home assistant os on an rpi4 fwiw.
Interesting, I also have hikvision cams, maybe I can make this work too. So far my lowest latency is via the synology integration, which is around 5 seconds when it refreshes, compared to 10-20 with default or ffmpeg cameras.
Okay, off to try that I guess.
Hmm, I just tried to google the hikvision camera platform but came up empty handed (assumed this must be new because I thought I would have noticed it earlier). Could you double check exactly what integration it is you are using?
Iām sorry. Iām an idiot. Iām using the hikvision integration for motion and event reporting, and the generic camera integration for the rtsp streams. So my experience is that using generic camera is better than onvif.
I have no idea how any of this actually works, but if it helps, Iām currently not using SSL on anything on the local network. So http into Lovelace. Over nabu casa, connecting over LTE, thereās about a 5 second delay before the stream goes live. No real lag after itās up and running.
No problem, just wanted to make sure I didnāt miss something. Is there any way I could get you to check your config and see how it compares to the below? I am also using local non-ssl connection when measuring latencyā¦ I wonder whatās differentā¦?
- platform: generic
name: Cam1
still_image_url: http://username:[email protected]/Streaming/Channels/1/picture
stream_source: rtsp://username:[email protected]:554/Streaming/Channels/101/
framerate: 4
I use the generic stream as well for hikvision cams and it seems to work fine. I get the streams from my NVR and use the substreams for most cams, but may upgrade to the full 4k stream in some instances (just not sure how well HA deals with H265+). This is how my cameras are set up in configuration.yaml
stream:
camera:
- platform: generic
name: Front 1
still_image_url: "http://USER:[email protected]/ISAPI/Streaming/channels/101/picture"
stream_source: "rtsp://USER:[email protected]:554/Streaming/Channels/102?transportmode=unicast&profile=Profile_1"
- platform: generic
name: Front 2
still_image_url: "http://USER:[email protected]/ISAPI/Streaming/channels/201/picture"
stream_source: "rtsp://USER:[email protected]:554/Streaming/Channels/202?transportmode=unicast&profile=Profile_1"
and the cards are set up like this
cards:
- type: picture-entity
camera_view: live
entity: camera.front_1
- type: picture-entity
camera_view: live
entity: camera.front_2
name: Camera - Front Porch
still_image_url: "http://user:[email protected]:85/ISAPI/Streaming/channels/101/picture"
stream_source: "rtsp://user:[email protected]:554/Streaming/channels/101"
I think X01 is the substream, but I have my substreams set to a pretty decent resolution. Good enough to see whatās going on, and good enough for DOODS. maybe thatās the difference. Iām viewing much lower resolution.
Edit: these are the main streams at 1080p@12fps
So I tried duplicating your configuration but I didnāt get any change in the 10-20 second lag on the cameras. Itās the same story for the main stream and substream. Iām at a loss at this point. Itās very frustrating to hear about people on the same cameras as me with everything working perfectly.
Maybe itās just that Iām on a 2011 mac mini and missing some processor functions it needs or maybe something else in my config is somehow affecting it. But I can go to the stream myself with VLC on another mac with a 2011 processor and itās quite fast. Iām tempted to just restart with a very simple ācamera onlyā config and see if I still have the same issue.
Out of curiosity, what server hardware and hass install are you running?
Is there anything I would have to do specially on the camera config to get multicast support from the camera? Maybe thatās something you do differently? I didnāt specifically set up multicastā¦ Do you have a multicast address defined at the bottom of the IP config of the camera/DVR
and is that the address you use in your camera config within hass?
So, just to take this to the extreme and be sure it had nothing to do with my hass configuration, I commented out everything in my entire config.yaml and lovelace-ui.yaml except 1 camera with only the substream going configured exactly as @D34DC3N73R described, and I had the exact same delay as beforeā¦ Even with everything enabled, Iām only at about 20% CPU and RAM and 40% diskā¦ Ughā¦
So itās got to be something in the camera config or something wrong with my server hardware. I donāt think itās something in my hass config.
No itās not, this is the normal behavior, see post linked below.
Thatās very old information that is from before the stream component became available.
I used to have my cameras configured exactly that way but I had the 10+ second delay in the lovelace card and only 1 frame every 10 seconds. If I clicked on it to get the detail view, I could get 1 frame every 5 seconds with almost real time update.
I still have some cameras configured this way for automatic popup on my kiosk tablets when people are spotted outside to give a slightly more realtime viewā¦ But not really very good with such a low framerate.
The guys above seem to have it working with the stream component, which means a good framerate of more than 1 FPS and realtime view in the lovelace card (at least from what it sounds like). Thatās what I want. I already have 10 second delay with good framerate, so going back to 1 frame every 10 seconds isnāt an upgrade.