Stream fixes (#22238)
* fix issues with out of order packets, and empty first packet on some IP camera models * do not skip the first packetpull/20830/head^2
parent
77635d40e2
commit
07dc23a0e3
|
@ -63,21 +63,29 @@ def stream_worker(hass, stream, quit_event):
|
|||
first_packet = True
|
||||
sequence = 1
|
||||
audio_packets = {}
|
||||
last_dts = None
|
||||
|
||||
while not quit_event.is_set():
|
||||
try:
|
||||
packet = next(container.demux(video_stream))
|
||||
if packet.dts is None:
|
||||
if first_packet:
|
||||
continue
|
||||
# If we get a "flushing" packet, the stream is done
|
||||
raise StopIteration
|
||||
raise StopIteration("No dts in packet")
|
||||
except (av.AVError, StopIteration) as ex:
|
||||
# End of stream, clear listeners and stop thread
|
||||
for fmt, _ in outputs.items():
|
||||
hass.loop.call_soon_threadsafe(
|
||||
stream.outputs[fmt].put, None)
|
||||
_LOGGER.error("Error demuxing stream: %s", ex)
|
||||
_LOGGER.error("Error demuxing stream: %s", str(ex))
|
||||
break
|
||||
|
||||
# Skip non monotonically increasing dts in feed
|
||||
if not first_packet and last_dts >= packet.dts:
|
||||
continue
|
||||
last_dts = packet.dts
|
||||
|
||||
# Reset segment on every keyframe
|
||||
if packet.is_keyframe:
|
||||
# Save segment to outputs
|
||||
|
|
Loading…
Reference in New Issue