Ignore packets with missing dts in peek_first_pts (#40299)

pull/40571/head
uvjustin 2020-09-21 09:26:24 +08:00 committed by Franck Nijhof
parent 3efda8d1d2
commit f1ee7fed4c
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
1 changed files with 7 additions and 1 deletions

View File

@ -113,7 +113,11 @@ def _stream_worker_internal(hass, stream, quit_event):
# Get to first video keyframe
while first_packet[video_stream] is None:
packet = next(container.demux())
if packet.stream == video_stream and packet.is_keyframe:
if (
packet.stream == video_stream
and packet.is_keyframe
and packet.dts is not None
):
first_packet[video_stream] = packet
initial_packets.append(packet)
# Get first_pts from subsequent frame to first keyframe
@ -121,6 +125,8 @@ def _stream_worker_internal(hass, stream, quit_event):
[pts is None for pts in {**first_packet, **first_pts}.values()]
) and (len(initial_packets) < PACKETS_TO_WAIT_FOR_AUDIO):
packet = next(container.demux((video_stream, audio_stream)))
if packet.dts is None:
continue # Discard packets with no dts
if (
first_packet[packet.stream] is None
): # actually video already found above so only for audio