From 97b59023d18be22c5e639193f9c1ac26cd80a747 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sat, 27 Feb 2021 11:20:58 -0800 Subject: [PATCH] Improve handling for recording start of nest cam stream (#47144) * Improve handling for start of nest cam stream Add negative_cts_offsets to segment container options in order to better handle recording at the start of a stream. Nest streams start off with a negative offset, and if the segment container does not support it, then it adjusts the timestamps making it out of order with the next segment as described in issue #46968 * Update homeassistant/components/stream/__init__.py Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com> Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com> --- homeassistant/components/stream/__init__.py | 1 + homeassistant/components/stream/worker.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/stream/__init__.py b/homeassistant/components/stream/__init__.py index 2d115c6978d..c2bf63063e5 100644 --- a/homeassistant/components/stream/__init__.py +++ b/homeassistant/components/stream/__init__.py @@ -258,6 +258,7 @@ class Stream: recorder.video_path = video_path self.start() + _LOGGER.debug("Started a stream recording of %s seconds", duration) # Take advantage of lookback hls = self.outputs().get("hls") diff --git a/homeassistant/components/stream/worker.py b/homeassistant/components/stream/worker.py index d5760877c43..773170449e1 100644 --- a/homeassistant/components/stream/worker.py +++ b/homeassistant/components/stream/worker.py @@ -25,7 +25,7 @@ def create_stream_buffer(video_stream, audio_stream, sequence): segment = io.BytesIO() container_options = { # Removed skip_sidx - see https://github.com/home-assistant/core/pull/39970 - "movflags": "frag_custom+empty_moov+default_base_moof+frag_discont", + "movflags": "frag_custom+empty_moov+default_base_moof+frag_discont+negative_cts_offsets", "avoid_negative_ts": "disabled", "fragment_index": str(sequence), }