From 818f64a641743605dafbd7e77a58abbebcbb0f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 4 Dec 2024 16:42:49 +0200 Subject: [PATCH] splitmuxsrc: Calculate the end offset of a fragment once known If a new fragment is added with a valid duration but no offset then the start offset is set later based on the end offset of the previous fragment. At that point the end offset of this fragment can also be calculated and not doing so would give the next fragment the same start offset. Part-of: --- .../gst/multifile/gstsplitmuxpartreader.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxpartreader.c b/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxpartreader.c index b3ea7da61c..13d339610f 100644 --- a/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxpartreader.c +++ b/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxpartreader.c @@ -1457,6 +1457,14 @@ gst_splitmux_part_reader_set_start_offset (GstSplitMuxPartReader * reader, reader->ts_offset = ts_offset; GST_INFO_OBJECT (reader, "Time offset now %" GST_TIME_FORMAT, GST_TIME_ARGS (time_offset)); + + if (!reader->need_duration_measuring + && reader->info.start_offset != GST_CLOCK_TIME_NONE) { + reader->end_offset = reader->info.start_offset + reader->info.duration; + GST_INFO_OBJECT (reader, "End offset set to %" GST_TIME_FORMAT, + GST_TIME_ARGS (reader->end_offset)); + } + SPLITMUX_PART_UNLOCK (reader); } @@ -1470,6 +1478,14 @@ gst_splitmux_part_reader_set_duration (GstSplitMuxPartReader * reader, GST_INFO_OBJECT (reader, "Duration manually set to %" GST_TIME_FORMAT, GST_TIME_ARGS (duration)); + + if (!reader->need_duration_measuring + && reader->info.start_offset != GST_CLOCK_TIME_NONE) { + reader->end_offset = reader->info.start_offset + reader->info.duration; + GST_INFO_OBJECT (reader, "End offset set to %" GST_TIME_FORMAT, + GST_TIME_ARGS (reader->end_offset)); + } + SPLITMUX_PART_UNLOCK (reader); }