Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slower than expected time to initial image #1769

Open
spiderjuka opened this issue Dec 16, 2024 · 19 comments
Open

Slower than expected time to initial image #1769

spiderjuka opened this issue Dec 16, 2024 · 19 comments
Labels
bug Something isn't working

Comments

@spiderjuka
Copy link

After update Frigate Card form version 5.2.0 to > 6.x.x I noticed a significant latency in the appearance of the camera image.
Version v5.2.0 has much less video latency when compared to v6.x.x (current 6.0.12)
For Frigate Card version 5.2.0 after switching to the camera the image from the camera is visible almost immediately. After update to version > 6.x.x (currently tested on 6.0.12) sometimes need to wait even 1-2 seconds which is problem when operating the intercom (Hikvison Doorbell).

My hardware configuration:
HAOS is installed on Dell Wyse 5070 (Intel J5005) with Proxmox.

Frigate Card setup:

type: custom:frigate-card
cameras:
  - camera_entity: camera.hikvision
    live_provider: go2rtc
    go2rtc:
      modes:
        - webrtc
menu:
  style: outside
  position: bottom
  buttons:
    microphone:
      enabled: true
      type: toggle
    screenshot:
      enabled: false
    download:
      enabled: false
    fullscreen:
      enabled: false
    snapshots:
      enabled: false
    timeline:
      enabled: false
    media_player:
      enabled: false
    clips:
      enabled: false
    live:
      enabled: false
    cameras:
      enabled: false
    frigate:
      enabled: false
    camera_ui:
      enabled: false
live:
  auto_mute: never
  controls:
    builtin: true
    title:
      mode: none
  layout:
    fit: fill
elements:
  - type: custom:frigate-card-menu-icon
    icon: mdi:volume-high
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: unmute
  - type: custom:frigate-card-menu-icon
    icon: mdi:volume-off
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: mute
  - type: custom:frigate-card-menu-icon
    icon: mdi:phone
    tap_action:
      - action: call-service
        service: button.press
        service_data:
          entity_id: button.ds_kv8213_answer_call
      - action: call-service
        service: button.press
        service_data:
          entity_id: button.ds_kv8213_hangup_call
      - action: custom:frigate-card-action
        frigate_card_action: unmute
      - action: custom:frigate-card-action
        frigate_card_action: microphone_unmute
  - type: custom:frigate-card-menu-icon
    icon: mdi:phone-hangup
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: microphone_mute
  - type: custom:frigate-card-menu-icon
    icon: mdi:door-open
    entity: switch.ds_kv8213_door_relay_0
    tap_action:
      action: toggle
  - type: custom:frigate-card-menu-icon
    icon: mdi:gate-open
    entity: switch.ds_kv8213_door_relay_1
    tap_action:
      action: toggle
dimensions:
  aspect_ratio: "16:9"
  aspect_ratio_mode: dynamic

I had to back to version 5.2.0 because I have no idea how to solev the problem.
Can you support me to solve it?

@spiderjuka spiderjuka added the bug Something isn't working label Dec 16, 2024
@dermotduffy
Copy link
Owner

Version v5.2.0 has much less video latency when compared to v6.x.x (current 6.0.12)

When you say video latency, do you mean (i) time from a blank page to first image to load, or do you mean (ii) delay between real-time and what you see on camera generally?

@spiderjuka
Copy link
Author

Version v5.2.0 has much less video latency when compared to v6.x.x (current 6.0.12)

When you say video latency, do you mean (i) time from a blank page to first image to load, or do you mean (ii) delay between real-time and what you see on camera generally?

Good question!
I mean time from a blank page to first image to load - that is big problem.

@dermotduffy
Copy link
Owner

I mean time from a blank page to first image to load - that is big problem.

Huh. OK. Can't say I noticed any difference. Let me try out your config.

@dermotduffy
Copy link
Owner

As a cursory check: Do you see anything unusual logged to your Javascript console? (F12 in Chrome)

@spiderjuka
Copy link
Author

Javascript console I will check today afternoon - when I will back to home.
At my hardware - Intel J5005 it is really noticeable difference.
The problem is that when someone calls home from the intercom, they have to wait a bit before the intercom image appears on the tablet. I didn't have this problem with version 5.2.0.

The configuration of the Frigate card I have provided above.
Below you can find the configuration for frigate itself:

mqtt:
  enabled: true
  host: 192.168.100.37
  user: mqtt
  password: mqtt

environment_vars:
  LIBVA_DRIVER_NAME: i965

cameras:
  Hikvision:
    detect:
      enabled: false

    ffmpeg:
      hwaccel_args: preset-vaapi

      inputs:
        - path: rtsp://admin:[email protected]:554/Streaming/Channels/101

go2rtc:
  streams:
    Hikvision:
      - rtsp://admin:[email protected]:554/Streaming/Channels/101
      - isapi://admin:[email protected]:80/

version: 0.14

@dermotduffy
Copy link
Owner

@spiderjuka Thanks. As well as checking the Javascript console, any chance you could take a short video clip / screen capture of the loading and what you see?

@dermotduffy dermotduffy changed the title Bigger latency in image appearance from the camera for since version > 6.0 Slower than expected time to initial image Dec 17, 2024
@spiderjuka
Copy link
Author

Below you can find some finding at Java console - I don't know if it is important or not?
But I noticed something interesting. You can reduce the delay time by touching the area where the camera image should appear with finger or mouse cursor - you can see this in the videos I sent as well.

Frigate Card v5.2.0 on Tablet - OK:
https://github.com/user-attachments/assets/010e9b82-702b-4179-8ab4-5d001969f5ee
Frigate Card v6.1.0 on Tablet - NOK:
https://github.com/user-attachments/assets/3204ccd1-f0c5-4c26-80f4-45904a649cf6
Frigate Card v6.1.0 on PC - NOK:
https://github.com/user-attachments/assets/67149307-41a3-4b0d-b694-d4ebaeb6675d
Java console:
Java_console

@spiderjuka
Copy link
Author

I noticed at frigate logs that during waiting time logs stoped at PTZ services:
Print_screen_Frigate_log_2
In addition in frigate logs are also errors --> Onvif is not setup for Hikvision:
Print_screen_Frigate_log_3

Is it possible that ptz service generate that waiting time to initial image from the camera?
Problem is that my camera has no Onvif function and I don't want use that function.
Is it possible to disable service: frigate.ptz.onvif - maybe it will solve my problem?

@dermotduffy
Copy link
Owner

dermotduffy commented Dec 18, 2024

Those logs are just Frigate being over loggy, that was fixed in a later Frigate release, I highly doubt it's related. You could try:

cameras:
  - camera_entity: camera.hikvision
    capabilities:
      disable:
        - ptz

Your issue looks like a rendering problem (the fact it updates when you move the mouse over it). The PTZ thing is just "another thing" the card needs to do at startup. My theory is the initialization is finished, but for some reason the card is not being re-rendered and then "coincidentally" re-renders when something else forces it to (e.g. mouse move).

@dermotduffy
Copy link
Owner

@spiderjuka Are you using any URL actions, i.e. query parameters in your dashboard URL?

@spiderjuka
Copy link
Author

Those logs are just Frigate being over loggy, that was fixed in a later Frigate release, I highly doubt it's related. You could try:

cameras:
  - camera_entity: camera.hikvision
    capabilities:
      disable:
        - ptz

Your issue looks like a rendering problem (the fact it updates when you move the mouse over it). The PTZ thing is just "another thing" the card needs to do at startup. My theory is the initialization is finished, but for some reason the card is not being re-rendered and then "coincidentally" re-renders when something else forces it to (e.g. mouse move).

I already did it - unfortunatelly still error in logs is present:

type: custom:frigate-card
cameras:
  - camera_entity: camera.hikvision
    live_provider: go2rtc
    go2rtc:
      modes:
        - webrtc
    capabilities:
      disable:
        - ptz

Onvif is not setup for Hikvision

@spiderjuka
Copy link
Author

spiderjuka commented Dec 18, 2024

@spiderjuka Are you using any URL actions, i.e. query parameters in your dashboard URL?

Yes, only for two buttons: one is nevigate to camera doorbel (lovelance) and second navigate to outside standard camera.
Code for camera doorbel button:

cards:
  - type: custom:stack-in-card
    mode: horizontal
    cards:
      - type: custom:button-card
        name: Videodomofon
        color: steelblue
        show_icon: true
        icon: mdi:doorbell-video
        tap_action:
          action: navigate
          navigation_path: /lovelace/doorbell
        styles:
          card:
            - aspect-ratio: 1/1
          name:
            - font-size: 15px
            - align-self: end
            - justify-self: center
          state:
            - font-size: 15px
          label:
            - font-size: 20px
          grid:
            - grid-template-areas: "\"i s\" \"l l\" \"n n\""
            - grid-template-columns: 40% 60%
            - grid-template-rows: 50% 20% 30%
          icon:
            - width: 80%

But it is important to note that in the Frigate Card v5.2.0 there was no PTZ error and there was no significant delay in the camera image appearing - why?

@dermotduffy
Copy link
Owner

Yes, only for two buttons: one is nevigate to camera doorbel (lovelance) and second navigate to outside standard camera.

When you don't use the URL actions, do you still have your delay?

But it is important to note that in the Frigate Card v5.2.0 there was no PTZ error

v5.2.0 could not automatically detect PTZ capabilities.

and there was no significant delay in the camera image appearing - why?

Well, that's the whole point of this issue, to find out :-) The codebase changed massively between v5.2.0 and now, so it could be any of thousands of lines of code.

@spiderjuka
Copy link
Author

Yes, only for two buttons: one is nevigate to camera doorbel (lovelance) and second navigate to outside standard camera.

When you don't use the URL actions, do you still have your delay?

But it is important to note that in the Frigate Card v5.2.0 there was no PTZ error

v5.2.0 could not automatically detect PTZ capabilities.

and there was no significant delay in the camera image appearing - why?

Well, that's the whole point of this issue, to find out :-) The codebase changed massively between v5.2.0 and now, so it could be any of thousands of lines of code.

I changed url to navigate and after I deleted button - still this same delay.
Second camera I have out of Frigate card.
This card work very well - without any problem:

square: false
type: grid
cards:
  - show_state: true
    show_name: true
    camera_view: live
    type: picture-entity
    entity: camera.ds_2cd2655fwd_izs20171218aawr145253995_101
columns: 1

But why still PTZ error exist in logs even capabilities was disabled for it?

@dermotduffy
Copy link
Owner

dermotduffy commented Dec 19, 2024

I changed url to navigate and after I deleted button - still this same delay.

Can you clarify what you mean by that? If you just manually go to a dashboard URL with a card, you get the same delay?

But why still PTZ error exist in logs even capabilities was disabled for it?

Camera capabilities are fetched, then disables are applied on top.

@dermotduffy
Copy link
Owner

BTW: If you try different live_providers (e.g. image, ha) do you get a different result?

@spiderjuka
Copy link
Author

I changed url to navigate and after I deleted button - still this same delay.

Can you clarify what you mean by that? If you just manually go to a dashboard URL with a card, you get the same delay?

But why still PTZ error exist in logs even capabilities was disabled for it?

Camera capabilities are fetched, then disables are applied on top.

Yes it is - dosen't meter how I do it - thru the button or manually - this same delay is.

@spiderjuka
Copy link
Author

BTW: If you try different live_providers (e.g. image, ha) do you get a different result?

I did it. After change deleay is this same, but two way audio was gone :( - provider must be go2rtc.

@dermotduffy
Copy link
Owner

OK -- thank you. Currently don't have much to go on here :-( I'll have to look into it / experiment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants