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

Alternative way to cast camera streams #1231

Closed
felipecrs opened this issue Jul 20, 2023 · 15 comments
Closed

Alternative way to cast camera streams #1231

felipecrs opened this issue Jul 20, 2023 · 15 comments
Labels
votes needed Vote for this feature to encourage prioritization!
Milestone

Comments

@felipecrs
Copy link
Contributor

felipecrs commented Jul 20, 2023

Is your feature request related to a problem? Please describe.
Casting camera streams from the Frigate Card is very easy, but the casted stream has a big problem: extremely high latency because it uses HLS format.

This makes it unusable for certain situations, like for example automatically showing some events in TVs as they happen or displaying the doorbell on the Nest Hub when someone rings.

Describe the solution you'd like
I figured there is a way to improve this, by a lot:

  1. Create a new, hidden, 1-panel layout dashboard. Call it Frigate Card:
    image

  2. Add a Frigate Card to this new dashboard. Mine looks like:

type: custom:frigate-card
cameras_global:
  live_provider: go2rtc
  go2rtc:
    modes:
      - webrtc
cameras:
  - camera_entity: camera.video_porteiro
    id: video_porteiro
    go2rtc:
      stream: video_porteiro_hd
performance:
  profile: low
dimensions:
  aspect_ratio_mode: static
  aspect_ratio: '16:9'
menu:
  style: none
live:
  auto_unmute: all
  controls:
    builtin: false
  zoomable: false
  lazy_unload: all
view:
  default: live

You can add as many camera entities you want, but make sure to hide the buttons if you intend to display it in a TV, for example. In my example, I'm also using the HD substream of my video_porteiro camera (doorbell).

  1. Then, you can cast this card with:
service: cast.show_lovelace_view
data:
  view_path: 0?frigate-card-action:camera_select=video_porteiro
  entity_id: media_player.tv_da_sala
  dashboard_path: frigate-card

Where from view_path you can select any camera you want through the query parameter.

The result? A quick and very low latency stream, with audio.

My point with this feature suggestion is:

It would be awesome if this process of casting the camera could be automated directly from the Send to media player button in the Frigate Card, so that I would not need to call this service manually each time.

Maybe something like:

type: custom:frigate-card
menu:
  buttons:
    media_player:
      enabled: true
      # Alters from current method to this new method
      method: cast_card
      # Expects that the user has a Frigate Card dashboard created already and configured as below
      cast_card:
        view_path: 0
        dashboard_path: frigate-card
cameras:
  - camera_entity: camera.video_porteiro
    # Optional, by default uses the same id as from the current card
    cast_card:
      id: video_porteiro

Describe alternatives you've considered
The alternative is to call the service manually. I can probably add some buttons in my dashboard to trigger this service more easily, but it would never be as easy and as integrated as from within the Frigate Card itself.

Additional context
N/A

@dermotduffy dermotduffy added the votes needed Vote for this feature to encourage prioritization! label Jul 29, 2023
@Neonox31
Copy link

Neonox31 commented Jul 31, 2023

Hi @felipecrs,

Nice idea, I upvoted 👍

By any chance, did you managed to get this working on a Google nest hub ?
On my side the google nest hub default image of home assistant cast is displayed in place of the camera but it works well on my chromecast ultra, maybe a decoding issue of the stream I presume.

EDIT: Finally it was a problem on my side preventing web rtc from working properly, sorry for the noise.

@felipecrs
Copy link
Contributor Author

BTW I had similar problems, until I switched the live provider to the WebRTC Card.

@dermotduffy
Copy link
Owner

Quick question on the intention @felipecrs :

    # Optional, by default uses the same id as from the current card
    cast_card:
      id: video_porteiro

Trying to figure out what is intended by the id parameter here. I think maybe there's a typo in the comment, and it should mean the camera to cast? I'm not sure why you'd ever want casting camera A, to cast a different camera, so maybe I'm not getting it!

@felipecrs
Copy link
Contributor Author

That's the card id, in case there are multiple cards in the same page.

@Neonox31
Copy link

@felipecrs Are you sure that cast.show_lovelace_view service accepts query parameters in view_path ?
On my side it doesn't seem to be working, but maybe I'm missing something ?

@felipecrs
Copy link
Contributor Author

Damn, it doesn't work indeed. In my case, I thought it was working because I was always testing with the first camera in the card.

Ok, so to make it work currently you have to actually create a dashboard for each camera then.

@felipecrs
Copy link
Contributor Author

I have reported as a bug to Hass: home-assistant/core#98316

@dermotduffy dermotduffy added this to the v6.0.0 milestone Aug 14, 2023
@felipecrs
Copy link
Contributor Author

Here is one quick demo on a Nest Hub to cast my brother's doorbell:

1_5116194257362748298.mp4

Next I want to check if 2-way audio works, but his house doesn't yet have a 2-way audio go2rtc capable camera yet.

If it works, it's gonna be awesome to answer the doorbell directly from the Nest Hub.

@Neonox31
Copy link

Neonox31 commented Sep 1, 2023

@felipecrs FYI I submitted #1244 because generic cameras are not correctly selected using query params, and after I think I will go with your solution to cast my cameras on my Google devices 👍

@dermotduffy
Copy link
Owner

I'm thinking the dashboard and method should perhaps be a property of the camera, not least because of home-assistant/core#98316 which would require a dashboard per camera, vs a property of the button:

That would look like:

type: custom:frigate-card

menu:
  buttons:
    media_player:
      enabled: true

cameras:
  - camera_entity: camera.video_porteiro
    cast:
      method: 'standard' | 'dashboard'
      dashboard:
        dashboard_path: frigate-card-dashboard
        view_path: mytab
        view_card_id: foo <--- defaults to this card's card-id
        view_camera_id: bar <--- defaults to this camera's id
        // This effectively resolves to this path: /frigate-card-dashboard/mytab?frigate-card-action.foo.camera_select=bar

// To use the same method / path for all cameras
cameras_global:
  cast:
  // Supports all the arguments shown above

@felipecrs Does this look right to you?

@felipecrs
Copy link
Contributor Author

Yes, absolutely!

@dermotduffy
Copy link
Owner

Prepared a PR, pretty cool to see a low latency feed on my Nest hub!

At least in my experimentation, on my device, using a view path with query arguments didn't load a view at all (i.e. it complained the view with the query string was not found, vs loading the view and ignoring the query string). As such, for now I have completely omitted the query string part of this (including the view_card_id and view_camera_id parameters I mentioned above). So it would require a manually created dashboard per camera. My guess is people would be most likely care about this for their front door where low latency is very important, so still probably useful even in this form.

@felipecrs
Copy link
Contributor Author

I agree. And maybe the issue will be fixed upstream in the future too.

@dermotduffy
Copy link
Owner

Will be in the next build.

@felipecrs
Copy link
Contributor Author

#1296

Thanks a lot. I will try it out as soon as I can.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
votes needed Vote for this feature to encourage prioritization!
Projects
None yet
Development

No branches or pull requests

3 participants