From 104f459258cbede84f1571671642873eaab91456 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 23 Jul 2019 01:42:02 +0200 Subject: [PATCH] qtdemux: fix key unit seek corner case If a key unit seek is performed with a time position that matches the offset of a keyframe, but not its actual PTS, we need to adjust the segment nevertheless. For example consider the following case: * stream starts with a keyframe at 0 nanosecond, lasting 40 milliseconds * user does a key unit seek at 20 milliseconds * we don't adjust the segment as the time position is "over" a keyframe * we push a segment that starts at 20 milliseconds * we push a buffer with PTS == 0 * an element downstream (eg rtponviftimestamp) tries to calculate the stream time of the buffer, fails to do so and drops it --- gst/isomp4/qtdemux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index f9c83831fa..ad2192acbf 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -1394,9 +1394,10 @@ gst_qtdemux_adjust_seek (GstQTDemux * qtdemux, gint64 desired_time, if (next && kindex == -1) kindex = gst_qtdemux_find_keyframe (qtdemux, str, index, FALSE); - /* if the keyframe is at a different position, we need to update the - * requested seek time */ - if (index != kindex) { + /* Update the requested time whenever a keyframe was found, to make it + * accurate and avoid having the first buffer fall outside of the segment + */ + if (kindex != -1) { index = kindex; /* get timestamp of keyframe */