Issue with GStreamer Pipeline: Inconsistent MP4 File Durations and Decoding Errors

HI,
I’m working on a GStreamer pipeline to process an RTP stream containing MP2T packets. The pipeline demuxes the stream, decodes and re-encodes the video, and outputs both an RTP stream and segmented MP4 files using splitmuxsink. Here’s my pipeline:


GST_DEBUG=3 gst-launch-1.0 \
    udpsrc address=239.202.108.52 port=6310 do-timestamp=true timeout=60000000000 buffer-size=0 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP2T,payload=(int)103" !  rtpbin name=recv_rtp ! watchdog timeout=300000 ! rtpmp2tdepay2 ! tsparse set-timestamps=true ! tsdemux ! multiqueue ! h264parse ! queue ! decodebin ! videoconvert ! video/x-raw,format=RGBA ! videorate drop-only=true ! queue ! videoflip method=none ! queue ! videoconvert ! deinterlace method=vfir fields=top ! videoconvert ! videorate drop-only=true ! openh264enc ! h264parse ! splitmuxsink name=mp4mux max-size-time=10000000000 max-size-bytes=0 location=stream_%d.mp4 

While this works fine for some sources, I’m seeing inconsistent MP4 file durations (e.g., 16s, 6s, 12s) for other source this issue doesn’t occurs.

Without GST_DEBUG, I noticed frequent Redistribute latency... logs.

etting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
Redistribute latency...
WARNING: from element /GstPipeline:pipeline0/GstTSDemux:tsdemux0: CONTINUITY: Mismatch packet 9, stream 2 (pid 0x1011)
Additional debug info:
../gstreamer/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c(2782): gst_ts_demux_queue_data (): /GstPipeline:pipeline0/GstTSDemux:tsdemux0
Redistribute latency...

Errors Observed -

0:00:10.449183111 84605 0x7fd45403b1e0 ERROR                  libav :0:: mmco: unref short failure
0:00:10.465825945 84605 0x7fd45403b1e0 ERROR                  libav :0:: decode_slice_header error
0:00:10.465901908 84605 0x7fd45403b1e0 ERROR                  libav :0:: reference picture missing during reorder
0:00:10.465916354 84605 0x7fd45403b1e0 ERROR                  libav :0:: Missing reference picture, default is 65803
0:00:10.491030073 84605 0x7fd45403b1e0 WARN            videodecoder gstvideodecoder.c:3133:gst_video_decoder_prepare_finish_frame:<avdec_h264-0> decreasing timestamp (0:00:05.461545066 < 0:00:05.695109070)

Attached pipeline diagram when played with gst-play

Observations:

  • The stream appears to contain packet loss or corruption, which may be causing the decoding issues.

If the problem originates from the source, is there any way to mitigate or fix it within the pipeline? For example, are there specific elements or settings in GStreamer that can help handle source-specific errors or irregularities better?

Any insights, debugging tips, or suggestions would be greatly appreciated!

Hi,

I previously posted a question regarding the following libav errors logs on level=4

Log_level=4
baseparse gstbaseparse.c:4111:gst_base_parse_set_latency:<h264parse2> min/max latency 0:00:00.000000000, 0:00:00.000000000
0:00:14.108496738   270 0x559eea5d4800 INFO                   libav :0:: Found reference and non-reference fields in the same frame, which
0:00:14.108529771   270 0x559eea5d4800 INFO                   libav :0::  is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
0:00:14.108562626   270 0x559eea5d4800 INFO                   libav :0:: If you want to help, upload a sample of this file to https://streams.videolan.org/upload/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)
0:00:14.108574544   270 0x559eea5d4800 ERROR                  libav :0:: decode_slice_header error

These errors occur during H.264 video decoding, and I’m trying to understand their root cause. I suspect it could be related to a corrupted stream or missing reference frames, but I haven’t found any concrete solutions after searching online.

Has anyone encountered a similar issue or found a way to resolve it? Any insights or suggestions would be greatly appreciated.

Thank you in advance!