From 918d8820213bad0a905dc58c31ffa2f5cf37d9cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Cerveau?= Date: Wed, 5 May 2021 13:20:04 +0200 Subject: [PATCH] matroskademux: fix decoder glitches with H264 content To avoid decoder starvation causing glitches on screen, the demuxer shall clip only when the buffer is a key frame and the lace time is greater than the stop time. Fixes gst-editing-services#128 Part-of: --- gst/matroska/matroska-demux.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index ca74c86..940f842 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -4799,11 +4799,15 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, if (GST_CLOCK_TIME_IS_VALID (lace_time)) { GstClockTime last_stop_end; - /* Check if this stream is after segment stop */ - if (GST_CLOCK_TIME_IS_VALID (demux->common.segment.stop) && - lace_time >= demux->common.segment.stop) { + /* Check if this stream is after segment stop, + * but only terminate if we hit the next keyframe, + * to make sure that all frames potentially inside the segment + * are available to the decoder for decoding / reordering.*/ + if (!delta_unit && GST_CLOCK_TIME_IS_VALID (demux->common.segment.stop) + && lace_time >= demux->common.segment.stop) { GST_DEBUG_OBJECT (demux, - "Stream %d after segment stop %" GST_TIME_FORMAT, stream->index, + "Stream %d lace time: %" GST_TIME_FORMAT " after segment stop: %" + GST_TIME_FORMAT, stream->index, GST_TIME_ARGS (lace_time), GST_TIME_ARGS (demux->common.segment.stop)); gst_buffer_unref (sub); goto eos; -- 2.7.4