Stream H.264 video over rtp using gstreamer

abir picture abir · Jun 26, 2013 · Viewed 53.5k times · Source

I am newbie with gstreamer and I am trying to be used with it. My first target is to create a simple rtp stream of h264 video between two devices. I am using these two pipelines:

Sender: gst-launch-1.0 -v filesrc location=c:\\tmp\\sample_h264.mov ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5000

Receiver: gst-launch-1.0 -v udpsrc port=5000 ! rtpmp2tdepay ! decodebin ! autovideosink

But with the first one (the sender) I got the following error:

Setting pipeline to PAUSED ...
Pipeline is PE*R*O L(LgIsNtG- l.a.u.n
h-1.0:5788): CRITICAL **: gst_adapter_map: assertion `size > 0' failed
ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2812): gst_base_src_loop (): /GstPipeline:pipeline0/GstFileSrc:filesrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

I tried a lot of other configurations but I couldn’t find the right pipeline.

Some other information: Gstreamer version: 1.0.7 OS: Windows 7

Any idea/suggestion? Thx,

Answer

umläute picture umläute · Jun 26, 2013

filesrc will read the data from the given file as raw bytes; you cannot just encode these raw bytes with x264enc, you will need video-data for this to work. try adding a demuxer/decoder before re-encoding the stream), e.g. something like this:

Sender:

gst-launch-1.0 -v \
   filesrc location=/tmp/sample_h264.mov
   ! qtdemux \
   ! h264parse \
   ! ffdec_h264 \
   ! ffmpegcolorspace \
   ! x264enc \
   ! rtph264pay \
   ! udpsink host=127.0.0.1 port=5000

You should do a quick check whether this works by using a test video soure:

gst-launch-1.0 -v \
   videotestsrc 
   ! x264enc \
   ! rtph264pay \
   ! udpsink host=127.0.0.1 port=5000