'Streaming an mpeg2-ts video over RTP using gstreamer

I am trying to stream an mpeg2-ts video over RTP using gstreamer. I am using the following pipeline for the server:

gst-launch-0.10 -v filesrc location=/home/…/miracast_sample.mpeg ! rtpmp2tpay ! udpsink host=localhost port=5000 sync=false

The problem that I am facing is that I get directly an EOS event like described below:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstRTPMP2TPay:rtpmp2tpay0: timestamp = 3878456990
/GstPipeline:pipeline0/GstRTPMP2TPay:rtpmp2tpay0: seqnum = 50764
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 126835285 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

I can understand that it is running very fast but how to fix it?



Solution 1:[1]

You have set sync=FALSE, and that translates to "do not sync on timestamps, but process the buffer as fast as possible." Try and change it to TRUE, like so:

gst-launch-0.10 -v filesrc location=/home/…/miracast_sample.mpeg ! rtpmp2tpay ! udpsink host=localhost port=5000 sync=1

Solution 2:[2]

I had the same problem as you and my coworker suggested I insert a tsparse set-timestamps=true between the filesrc and rtpmp2tpay. It worked for me, so try changing your pipeline to

gst-launch-0.10 -v filesrc location=/home/…/miracast_sample.mpeg ! \
  tsparse set-timestamps=true ! rtpmp2tpay ! udpsink host=localhost port=5000 sync=false

Solution 3:[3]

Have you tried to demux it and then mux it ...

such as:

server:

gst-launch-0.10 -v filesrc location=file_to_stream.ts ! tsdemux program-number=811 ! mpegtsmux ! rtpmp2tpay ! udpsink host=localhost port=5000 sync=1

client:

gst-launch-0.10 udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP2T-ES" ! gstrtpbin ! rtpmp2tdepay ! tsdemux ! mpeg2dec ! ffmpegcolorspace ! autovideosink

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Havard Graff
Solution 2 Mutant Bob
Solution 3 Nuno Martins