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>
This commit is contained in:
Allen Porter 2021-02-27 11:20:58 -08:00 committed by GitHub
parent 49315a90d9
commit 97b59023d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View file

@ -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")

View file

@ -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),
}