mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Round up for stream record lookback (#75580)
This commit is contained in:
parent
06115bcbff
commit
a612d7a0f3
@ -503,15 +503,16 @@ class Stream:
|
|||||||
|
|
||||||
await self.start()
|
await self.start()
|
||||||
|
|
||||||
|
self._logger.debug("Started a stream recording of %s seconds", duration)
|
||||||
|
|
||||||
# Take advantage of lookback
|
# Take advantage of lookback
|
||||||
hls: HlsStreamOutput = cast(HlsStreamOutput, self.outputs().get(HLS_PROVIDER))
|
hls: HlsStreamOutput = cast(HlsStreamOutput, self.outputs().get(HLS_PROVIDER))
|
||||||
if lookback > 0 and hls:
|
if hls:
|
||||||
num_segments = min(int(lookback // hls.target_duration), MAX_SEGMENTS)
|
num_segments = min(int(lookback / hls.target_duration) + 1, MAX_SEGMENTS)
|
||||||
# Wait for latest segment, then add the lookback
|
# Wait for latest segment, then add the lookback
|
||||||
await hls.recv()
|
await hls.recv()
|
||||||
recorder.prepend(list(hls.get_segments())[-num_segments - 1 : -1])
|
recorder.prepend(list(hls.get_segments())[-num_segments - 1 : -1])
|
||||||
|
|
||||||
self._logger.debug("Started a stream recording of %s seconds", duration)
|
|
||||||
await recorder.async_record()
|
await recorder.async_record()
|
||||||
|
|
||||||
async def async_get_image(
|
async def async_get_image(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user