dahua icon indicating copy to clipboard operation
dahua copied to clipboard

Streaming the camera to a media player uses internal url

Open michaelwoods opened this issue 2 years ago • 2 comments

Version of the custom_component

0.9.23

Configuration


service: camera.play_stream
data:
  media_player: media_player.bedroom_home_hub
target:
  entity_id:
    - camera.front_door_main

Describe the bug

The stream will fail to play and the logs show that an internal_url was used (http://ip_address/...) when I do not have that defined in my configuration. I do have external_url only, to avoid this issue with casting devices.

Debug log

Failed to cast media http://ip_address:8123/api/hls/dd56f293afd20bed8fad30c64b7bde11198bc2d66108f2edc7821a23b354d6b8/master_playlist.m3u8 from internal_url (http://ip_address:8123). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

Note that I replaced my real internal address with ip_address above.

michaelwoods avatar Sep 27 '21 19:09 michaelwoods

Hmm, I'm not sure what to do here. I get what you are trying to do, and to cast some of these devices need a public facing URL. But I'm not sure how to make your external_url map to your internal IP address. If you have multiple cameras, how would HA know which one to route to just from the external URL alone?

rroller avatar Oct 04 '21 00:10 rroller

For multiple cameras, the internal_url is still the same. It's the Home Assistant http url not camera IPs. The path would be different per camera, essentially HA proxies the stream itself. At least that's my understanding of how HA handles cameras and streaming.

Example:

http://ip_address:8123/api/hls/foo
http://ip_address:8123/api/hls/bar

would become

https://my.external.domain/api/hls/foo
https://my.external.domain/api/hls/bar

The method that this component uses to report its camera's address for the play_stream service would need to reference the external_url for a cast-device to play it.

michaelwoods avatar Oct 05 '21 19:10 michaelwoods