Stream H.264 video over rtp using gstreamer
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
abir
Updated on July 28, 2020Comments
-
abir almost 4 years
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,
-
abir about 11 yearsThank you for the hint raw/video data but I think this solves just one par of the problem. I tried the classic pipeline with videotestsrc but nothing is going to the other side. Even with the following pipeline I cannot receive anything on the other side:
gst-launch-1.0 -v videotestsrc ! udpsink host=192.128.52.128 port=9001
I have the feeling that the udpsink is not sending anything! PS: is not a problem of firewall, I deactivate all of them -
abir about 11 yearsTrying with:
ffmpeg -i C:\tmp\sample_h264.mov -f mpegts udp://192.168.52.128:9001
… and the stream is received in the other side. But I want to do it with gstreamer -
umläute about 11 years
videotestsrc ! udpsink
is not an RTP stream. you have to add a payloader -
abir about 11 years
gst-launch-1.0 -v videotestsrc ! udpsink host=192.128.52.128 port=9001
output:Setting pipeline to PAUSED ... Pipeline is PREROLLING ... /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1 /GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)320, height=(int)240, framerate=(fraction)30/1 Pipeline is PREROLLED ... Setting pipeline to PLAYING ... New clock: GstSystemClock
-
abir about 11 yearsEven with rtph264pay I had the same result
-
abir about 11 yearsFinally, I think that the problem was related to Windows. The two following pipelines work fine between two different Ubuntu VMs but not on Windows: Sender:
gst-launch-1.0 -v filesrc location=/home/ … /sample_h264.mov ! decodebin ! x264enc ! rtph264pay ! udpsink host=192.168.52.129 port=9001
Receiver:gst-launch-1.0 -v udpsrc port=9001 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! autovideosink