mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 00:07:10 +00:00
Use stream to generate fallback image for onvif (#75584)
This commit is contained in:
parent
2b2ea3dd73
commit
891158f332
@ -136,13 +136,16 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera):
|
|||||||
self, width: int | None = None, height: int | None = None
|
self, width: int | None = None, height: int | None = None
|
||||||
) -> bytes | None:
|
) -> bytes | None:
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
image = None
|
|
||||||
|
if self.stream and self.stream.keepalive:
|
||||||
|
return await self.stream.async_get_image(width, height)
|
||||||
|
|
||||||
if self.device.capabilities.snapshot:
|
if self.device.capabilities.snapshot:
|
||||||
try:
|
try:
|
||||||
image = await self.device.device.get_snapshot(
|
image = await self.device.device.get_snapshot(
|
||||||
self.profile.token, self._basic_auth
|
self.profile.token, self._basic_auth
|
||||||
)
|
)
|
||||||
|
return image
|
||||||
except ONVIFError as err:
|
except ONVIFError as err:
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
"Fetch snapshot image failed from %s, falling back to FFmpeg; %s",
|
"Fetch snapshot image failed from %s, falling back to FFmpeg; %s",
|
||||||
@ -150,17 +153,14 @@ class ONVIFCameraEntity(ONVIFBaseEntity, Camera):
|
|||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
|
|
||||||
if image is None:
|
assert self._stream_uri
|
||||||
assert self._stream_uri
|
return await ffmpeg.async_get_image(
|
||||||
return await ffmpeg.async_get_image(
|
self.hass,
|
||||||
self.hass,
|
self._stream_uri,
|
||||||
self._stream_uri,
|
extra_cmd=self.device.config_entry.options.get(CONF_EXTRA_ARGUMENTS),
|
||||||
extra_cmd=self.device.config_entry.options.get(CONF_EXTRA_ARGUMENTS),
|
width=width,
|
||||||
width=width,
|
height=height,
|
||||||
height=height,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
return image
|
|
||||||
|
|
||||||
async def handle_async_mjpeg_stream(self, request):
|
async def handle_async_mjpeg_stream(self, request):
|
||||||
"""Generate an HTTP MJPEG stream from the camera."""
|
"""Generate an HTTP MJPEG stream from the camera."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user