Why are IP cameras so slow in frontend?!

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
image
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.

I’m sitting on a laptop on my LAN right now. I open a new tab and click my bookmark to my default lovelace view that has 1 stream on it (preloaded). The page takes less than a second to load and then the stream goes live in less than a second after that. I think my substream is at 6fps, and it looks like its not too much worse than that in my browser. Definitely better than 1fps.

I just don’t know how any of this works below the surface otherwise i may be able to help you understand why my results are different than yours. If it helps, i’m running HA on a pi4 w/ 4gb ram. Very few add-ons, and my typical resting CPU load is around 4 or 5%.

Oh, and my little test up there is on an old macbook air, like 2011 or 2012 i5 w/ 4gb ram.

I really appreciate all the help. At this point, I think it must be on the camera side… Is there any way you could log into your camera and send me the config of the following tabs?

Video/Audio->Video

Local

You could just screenshot the parts other than network or anything you don’t want to share. I’m especially interested if it might be due to multicasting, though I can’t think of why this would matter.

This is the camera in question. Here’s the main stream:
Screen Shot 2020-07-28 at 5.16.39 PM

and the substream:
Screen Shot 2020-07-28 at 5.17.27 PM

Let me know if you want to see anything else. The rest is pretty typical. I don’t know what multicasting is, so unless it is enabled by default i’m not doing it. My DVR is plugged into a netgear R7960P router, as are my two pi4’s. One is running HA OS and the other running doods and node-red on raspbian.

I have a typical 1gbps down 40mbps up service through my cable company. Usually see around 600mbps down and 35 up.

Got it, my misunderstanding.

I just added to my configure as below, and getting 1fps on the frontend.

  - platform: generic
    name: Cam03_main
    still_image_url: "http://admin:[email protected]/ISAPI/Streaming/channels/101/picture"
    stream_source: "rtsp://admin:[email protected]:554/Streaming/channels/101"

FYI:
rtsp://192.168.1.168:10554/Streaming/channels/101 – get the mainstream of the 1st channel
rtsp://192.168.1.168:10554/Streaming/channels/102 – get the sub stream of the 1st channel

1 Like

FYI: No stream using H.265

Yeah you have a bit of a different situation since you are getting your feed from the NVR. I am getting my stream straight from the camera, so it would be good to see your camera config if you know how to log into them. That’s where most of the important stuff is configured.

That’s basically identical to how mine are set up (main stream and substream are the same 10-20 second delay). I get a good framerate >1fps, but just a 10-20 second delay between the actual real life event and when I can see it on the frontend.

I’ll poke around, but don’t forget I’m using TVI cameras over coax, not ip cameras. But let me see if there’s more camera specific information in there.

Edit. I’m accessing the DVR through the hikvision iVMS-4200 application. The only other page of info related to camera streams is here (though this may be just related to PTZ control over coax?)
Screen Shot 2020-07-28 at 5.55.39 PM

Ok so it is not a framerate issue or a comm issue. Somehow, your frames are getting buffered in memory before getting displayed. 10mins of frames is a lot. I have had similar issues while developing my ffmpeg component using a coroutine as I am a bit of a newb with python but ended up resolving it. Are you recording your stream somewhere? Is you camera for example recording to and SD card?

Nope, no recording. And I even tested turning off all the components except the stream: component and the camera: component and having a UI with only one card, the picture elements card with the camera feed and had the same issue. I can open the same feed in VLC on very similar hardware and see it in perfect near real time.

Oh and it’s 10 seconds, not 10 minutes, that was a typo.

Not sure if gifs load here, but if it helps, here’s a clip of my experience at home. Please let me know if you guys see something that I missed that should have been obfuscated:

I have a very similar experience… I am currently loading 16 streams in screen in less than 1s but that is because many of them are running live in the background.

My card also shows up relatively quickly when I load up the dashboard (though not as good as yours), and has good framerate. It’s just that what is displayed in the card is 10-20 seconds slower than what is happening in real life.