Seeking pipeline performing MPEG-TS -> MP4 conversion

Hi,

I’m playing with the following pipeline:

gst-launch-1.0 filesrc location=playlist.m3u8 ! hlsdemux ! concat ! tsdemux name=demux  mp4mux name=mux ! filesink location=final.mp4 demux. ! queue ! h264parse ! mux. demux. ! queue ! aacparse ! mux.

The purpose of it is to concatenate and convert the HLS segmented video file to mp4 format. The input HLS segments are AVC/AAC encoded. The pipeline generates the file as expected. I have implemented that pipeline programatically. Now I’m trying to add there support for the segment seek, for instance in order to trim beginning and the end of the HLS segmented stream. When doing that I encountered the following issue:

GStreamer-CRITICAL **: 23:01:03.736: gst_segment_do_seek: assertion 'segment->format == format' failed

When running the pipeline with the GST_DEBUG=5 I see the following log entries:

0:00:00.020562000 51265 0x600000006fa0 INFO               GST_EVENT gstevent.c:1394:gst_event_new_seek: creating seek rate 1.000000, format TIME, flags 3, start_type 1, start 0:01:40.000000000, stop_type 1, stop 0:07:00.000000000
0:00:00.020568000 51265 0x600000006fa0 INFO              aggregator gstaggregator.c:2435:gst_aggregator_do_seek:<mp4mux> starting SEEK

(hlstest:51265): GStreamer-CRITICAL **: 23:01:49.172: gst_segment_do_seek: assertion 'segment->format == format' failed
0:00:00.020583000 51265 0x600000006fa0 INFO              aggregator gstaggregator.c:1531:gst_aggregator_stop_srcpad_task:<mp4mux> Pausing srcpad task

It looks like the problem is raised by the mp4mux element, but it is not clear yet to me why that happens and how to have it working. When implementing the seeking I was following Pipeline manipulation. My seek event uses GST_FORMAT_TIME.

I’m not using GST_SEEK_FLAG_SEGMENT flag so this issue does not hit me: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/554.

BTW, is there any plan to add support for segment seeking to adaptivedemux soon/at all? How difficult that would be? Could you give me some hints on how to approach that if I would like to do it on my own?