Broadcast MPEG-PS Stream over RTP with Specific Payload Type in MPEG using GStreamer

Broadcasting an MPEG Program Stream (PS) over RTP using GStreamer. I need to ensure that the RTP packets use a specific payload type (96). Below is the pipeline I am using for broadcasting:

gst-launch-1.0 filesrc location=file_name.mpg ! queue ! mpegvideoparse ! mpegpsmux ! rtpgstpay pt=96 ! udpsink host= port=5002

Stream information-

Reciver side -

gst-launch-1.0 udpsrc port=5002 ! application/x-rtp,media=video,clock-rate=90000,payload=96 ! rtpjitterbuffer ! rtph264depay ! autovideosink

Issues Encountered:

(gst-launch-1.0:29581): GStreamer-CRITICAL **: 16:01:48.041: gst_segment_to_running_time: assertion 'segment->format == format' failed
0:00:01.206370290 29581 0x5cfbd2821180 WARN               mpegpsmux mpegpsmux.c:421:mpegpsmux_queue_buffer_for_stream:<mpegpsmux0:pad0> got DTS without PTS
(gst-launch-1.0:29581): GStreamer-CRITICAL **: 16:01:48.042: gst_segment_to_running_time: assertion 'segment->format == format' failed
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:01.190651279
Setting pipeline to NULL ...
Freeing pipeline ...

Another gstreamer pipeline for ps stream broadcasting.

gst-launch-1.0 filesrc location=file_name.mpg ! mpegvideoparse ! rtpmpvpay pt=96 ! udpsink host= port=5002

The receiver side is not able to receive the stream (Using gstreamer pipeline).

Output using ffplay -

GStreamer Version: 1.24

Any insights, suggestions, or examples of similar pipelines that work would be greatly appreciated. Thank you!

You’re using rtpgstpay or rtpmpvpay on the sender, and rtph264depay on the receiver. That can’t work. You need to use compatible payloaders and depayloaders.

Also you’re putting MPEG-2 into the stream (either in MPEG-PS container or plain elementary stream) but try to get H264 out of the stream. They’re different codecs.

I want to broadcast using the MPEG-2 format, not H264. Is this feasible with my current setup, and what would be the best approach to ensure compatibility?

MPEG-2 video elementary stream, or an MPEG-PS stream (that might contain MPEG-2 video and maybe audio too)? Over RTP or just as is?

MPEG-PS stream
only video
I want to set the payload.

There’s no RTP payloader for MPEG-PS in GStreamer, only a depayloader (rtpmp1sdepay). You’d have to write (and ideally contribute) a payloader for that, or use a different format.

If it’s video only, you could use rtpmpvpay and rtpmpvdepay which would handle a MPEG-2 video elementary stream.

1 Like

Also, since the file is an MPEG-PS container you should use filesrc ! mpegpsdemux ! mpegvideoparse, just processing it with an mpegvideoparse might somewhat work if you’re lucky and extract bits of the MPEG-2 video elementary stream at least, but you might get other garbage in between or miss out on data, depends a bit on how the file is muxed.

This is not an answer if your question was about streaming MPEG-PS.
Though, if your use case is just streaming the video content with ability to set payload, as workaround you may stream MP2 TS over RTP.

I just made a quick mpeg ps file (using MPEG-2 System Stream) and the following seems working:


gst-launch-1.0 filesrc location=mpeg_ps.mpg ! mpegpsdemux ! mpegvideoparse ! mpegtsmux ! rtpmp2tpay pt=97 ! udpsink host= port=5002


gst-launch-1.0 udpsrc address= port=5002 ! application/x-rtp,encoding-name=MP2T,clock-rate=90000,payload=97 ! rtpjitterbuffer latency=0 ! rtpmp2tdepay ! decodebin ! autovideoconvert ! autovideosink

Here using dynamic payload 97 instead of static payload 33 for RTP/MP2T.
Here streaming to localhost, for UDP over LAN you may have to use higher latency.