GStreamer RTP full-duplex video in/out with single rtpbin - gstreamer

I'm trying to create gstreamer pipeline with rtpbin to stream webcam both way (videophone). However, I am not even able to make rtpbin work with simple snippet like below which just takes webcam source and streams out, then other udpsrc captures RTP packets and displays. All localhost. When splitted to two pipes and launched separately, it works. This, however, not. I feel it has something with threading, however I am stucked here as no queue worked for me so far.
Basically, what I need is displaying incomming videostream and stream out my webcam videostream out to remote party.
gst-launch -v \
gstrtpbin name=rtpbin \
udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263" port=5000 ! rtpbin. \
rtpbin. ! rtph263depay ! ffdec_h263 ! ffmpegcolorspace ! xvimagesink \
v4l2src ! video/x-raw-yuv, framerate=30/1, width=320, height=240 ! videoscale ! videorate ! "video/x-raw-yuv,width=352,height=288,framerate=30/1" ! ffenc_h263 ! rtph263pay ! rtpbin. \
rtpbin. ! udpsink port=5000

Ok, I have to answer to myself, it was enough to add sync=false async=false to the udpsink:
gst-launch -v \
gstrtpbin name=rtpbin udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263" port=5000 ! queue ! rtpbin. \
rtpbin. ! rtph263depay ! ffdec_h263 ! ffmpegcolorspace ! xvimagesink \
v4l2src ! video/x-raw-yuv, framerate=30/1, width=320, height=240 ! videoscale ! videorate ! "video/x-raw-yuv,width=352,height=288,framerate=30/1" ! ffenc_h263 ! rtph263pay ! rtpbin. \
rtpbin. ! udpsink port=5000 sync=false async=false

Related

Gstreamer get video from camera, resize it, and copy it ito two sinks

I have one camera and I would like to clone it to be able to use it in two different apps.
The following two things work ok, but I'm not able to combine them:
Read from /dev/video0 and clone to /dev/video1 and /dev/video2
gst-launch-1.0 v4l2src name=vsrc device=/dev/video0 ! \
video/x-raw,width=1920,height=1080,framerate=60/1,format=RGB ! \
tee name=t ! queue ! v4l2sink device=/dev/video1 t. ! \
queue ! v4l2sink device=/dev/video2
Read from /dev/video0 and rescale it and output to /dev/video1
gst-launch-1.0 v4l2src name=vsrc device=/dev/video0 ! \
video/x-raw,width=1920,height=1080,framerate=60/1,format=RGB ! \
videoscale ! video/x-raw,width=178,height=100 ! videoconvert ! \
v4l2sink device=/dev/video1
But the following does not work (reading -> rescaling -> clone)
gst-launch-1.0 v4l2src name=vsrc device=/dev/video0 ! \
video/x-raw,width=1920,height=1080,framerate=60/1,format=RGB ! \
videoscale ! video/x-raw,width=178,height=100 ! videoconvert ! \
tee name=t ! queue ! v4l2sink device=/dev/video1 t. ! \
queue ! v4l2sink device=/dev/video2
It fails with the following error:
ERROR: from element /GstPipeline:pipeline0/GstVideoScale:videoscale0: Failed to configure the buffer pool
Additional debug info:
gstbasetransform.c(904): gst_base_transform_default_decide_allocation (): /GstPipeline:pipeline0/GstVideoScale:videoscale0:
Configuration is most likely invalid, please report this issue.
Thanks!

Multiple RTMP inputs - picture in picture - stream offline handling

I'm using gstreamer to make a picture-in-picture composition of two rtmp inputs into an rtmp output.
I've managed to create a pipeline that works very well when both streams are offline
However, when one of the rtmp streams is not live when starting the pipeline - the pipeline does not start.
Does anyone know how to overcome this issue, and make sure the pipeline is not blocked if one rtmp source is offline?
You may have to insert identity into compositor input sub-pipelines.
Simulating 2 sources on localhost with:
gst-launch-1.0 videotestsrc ! x264enc insert-vui=1 ! h264parse config-interval=1 ! mpegtsmux ! rtpmp2tpay ! udpsink port=5004
(and second source the same to port 5005), the following runs fine for 0, 1 or 2 sources active at launch time:
gst-launch-1.0 -v \
udpsrc port=5004 ! application/x-rtp,media=video,encoding-name=MP2T,clock-rate=90000,payload=33 ! rtpjitterbuffer latency=300 ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_0 \
udpsrc port=5005 ! application/x-rtp,media=video,encoding-name=MP2T,clock-rate=90000,payload=33 ! rtpjitterbuffer latency=300 ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_1 \
compositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_0::width=320 sink_0::height=240 sink_1::xpos=0 sink_1::ypos=240 sink_1::width=320 sink_1::height=240 ! video/x-raw,width=320,height=480 ! videoconvert ! xvimagesink
For rtmp, with mpeg audio from first source, it would be something like:
gst-launch-1.0 -v \
rtmpsrc <your source1 and options> ! flvdemux name=demux0 ! queue ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_0 \
rtmpsrc <your source2 and options> ! flvdemux name=demux1 ! queue ! h264parse ! avdec_h264 ! videoconvert ! identity ! queue ! comp.sink_1 \
compositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_0::width=320 sink_0::height=240 sink_1::xpos=0 sink_1::ypos=240 sink_1::width=320 sink_1::height=240 ! video/x-raw,width=320,height=480 ! videoconvert ! autovideosink \
demux0. ! queue ! audio/mpeg ! decodebin ! audioconvert ! audioresample ! autoaudiosink

Gstreamer multiple sinks not working

I am trying to get a stream from the webcam and then using tee to get two sinks(filesink and autovideosink) so I can visualise the video in a window and in the same time save it into a folder. When I run this command I get only a frozen image in the window and not a video stream. It works with two autovideosinks(I get two windows with two videostreams) so I guess the problem is in the filesink part. The filesink works perfectly alone.
gst-launch-1.0 -v v4l2src device=/dev/video0 ! tee name=t \
t. ! queue ! videoscale ! video/x-raw,framerate=30/1,width=320,height=240 ! \
videoconvert ! autovideosink \
t. ! queue ! video/x-raw,framerate=30/1,width=320,height=240 ! \
x264enc ! mpegtsmux ! filesink location=~/Videos/test1.mp4
Try to add async=0 property to filesink.
gst-launch-1.0 -v v4l2src device=/dev/video0 ! tee name=t \
t. ! queue ! videoscale ! video/x-raw,framerate=30/1,width=320,height=240 ! \
videoconvert ! autovideosink \
t. ! queue ! video/x-raw,framerate=30/1,width=320,height=240 ! \
x264enc ! mpegtsmux ! filesink **async=0** location=~/Videos/test1.mp4

Stream audio and video with gstreamer

I'm trying to stream an arbitrary file with gstreamer, I have the following command line but it does not work (I will use python when I get this to work)
gst-launch-1.0 uridecodebin uri=file:///tmp/File.mkv name=decoder name=decbin \
! queue\
! videoconvert ! x264enc \
! mp4mux name=muxer ! udpsink host=127.0.0.1 port=1234 decbin. \
! queue \
! audioconvert ! lamemp3enc ! muxer.
and playing with
gst-launch-1.0 udpsrc port=1234 ! 'application/x-rtp,payload=96'\
! rtph264depay ! decodebin ! xvimagesink sync=false
I know I have to add rtph264pay and rtpmpapay but I don't know where.

Gstreamer stream h264 File

I'm trying to stream a h264 encoded movie file from a server to multiple clients at once by sending the RTP Stream to the broadcast address.
The solution I've got works but is very slow. Playing the video locally works fine.
Here's my Server:
gst-launch-0.10 -v filesrc location=/home/zeroc8/Videos/bunny.mov \
! qtdemux ! h264parse ! rtph264pay pt=96 ! udpsink host=192.168.1.255 port=5000
This is the Client:
gst-launch-0.10 udpsrc port=5000 \
caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\"J01AHqkYGwe83gDUBAQG2wrXvfAQ\\,KN4JyA\\=\\=\", payload=(int)96, ssrc=(uint)786848209, clock-base=(uint)101553131, seqnum-base=(uint)64602"
! rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! autovideosink
Am I doing something bad here? Why is this so slow?
Just got the answer from the gstreamer mailing list.
In case anyone else is having the same problem, adding the gstrtpjitterbuffer element fixes it.
gst-launch-0.10 udpsrc port=5000 \
caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\"J01AHqkYGwe83gDUBAQG2wrXvfAQ\\,KN4JyA\\=\\=\", payload=(int)96, ssrc=(uint)786848209, clock-base=(uint)101553131, seqnum-base=(uint)64602" \
! gstrtpjitterbuffer latency=1000
! rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! autovideosink