mirror of
https://github.com/home-assistant/core.git
synced 2025-06-10 08:07:06 +00:00
Skip invalid segments in stream recorder (#70896)
* Skip segment if duration is None * Copy segments deque before passing to thread
This commit is contained in:
parent
485ae70308
commit
9281f46bcd
@ -60,6 +60,10 @@ def recorder_save_worker(file_out: str, segments: deque[Segment]) -> None:
|
|||||||
"r",
|
"r",
|
||||||
format=SEGMENT_CONTAINER_FORMAT,
|
format=SEGMENT_CONTAINER_FORMAT,
|
||||||
)
|
)
|
||||||
|
# Skip this segment if it doesn't have data
|
||||||
|
if source.duration is None:
|
||||||
|
source.close()
|
||||||
|
continue
|
||||||
source_v = source.streams.video[0]
|
source_v = source.streams.video[0]
|
||||||
source_a = source.streams.audio[0] if len(source.streams.audio) > 0 else None
|
source_a = source.streams.audio[0] if len(source.streams.audio) > 0 else None
|
||||||
|
|
||||||
@ -137,7 +141,7 @@ class RecorderOutput(StreamOutput):
|
|||||||
thread = threading.Thread(
|
thread = threading.Thread(
|
||||||
name="recorder_save_worker",
|
name="recorder_save_worker",
|
||||||
target=recorder_save_worker,
|
target=recorder_save_worker,
|
||||||
args=(self.video_path, self._segments),
|
args=(self.video_path, self._segments.copy()),
|
||||||
)
|
)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user