From 508a565163990e6f24e00d73f0b9715eec668443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 15 Jul 2021 12:02:40 +0200 Subject: matroska: demux: update stream_start_time The stream_start_time can be less than the first detected. In case of B-Frame based media, the first frame PTS might be greater than the next one. Need to keep the segment.start if a seek has been performed. Part-of: --- gst/matroska/matroska-demux.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 3f03b707f..75319bc95 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -4611,6 +4611,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, gboolean delta_unit = FALSE; guint64 duration = 0; gint64 lace_time = 0; + gboolean keep_seek_start = TRUE; GstEvent *protect_event; stream = g_ptr_array_index (demux->common.src, stream_num); @@ -4639,6 +4640,15 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, } /* need to refresh segment info ASAP */ + if (GST_CLOCK_TIME_IS_VALID (lace_time) + && GST_CLOCK_TIME_IS_VALID (demux->stream_start_time) + && lace_time < demux->stream_start_time) { + keep_seek_start = + (demux->common.segment.start > demux->stream_start_time); + demux->stream_start_time = lace_time; + demux->need_segment = TRUE; + } + if (GST_CLOCK_TIME_IS_VALID (lace_time) && demux->need_segment) { GstSegment *segment = &demux->common.segment; guint64 clace_time; @@ -4651,10 +4661,10 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux, GST_TIME_ARGS (lace_time)); } clace_time = MAX (lace_time, demux->stream_start_time); - if (GST_CLOCK_TIME_IS_VALID (demux->common.segment.position) && - demux->common.segment.position != 0) { - GST_DEBUG_OBJECT (demux, - "using stored seek position %" GST_TIME_FORMAT, + if (keep_seek_start + && GST_CLOCK_TIME_IS_VALID (demux->common.segment.position) + && demux->common.segment.position != 0) { + GST_DEBUG_OBJECT (demux, "using stored seek position %" GST_TIME_FORMAT, GST_TIME_ARGS (demux->common.segment.position)); clace_time = demux->common.segment.position; } -- cgit v1.2.1