I'm trying to make a server and client application that sends and receives a raw video stream using rtpbin. In order to send an uncompressed videostream I'm using rtpgstpay and rtpgstdepay to payload to the data.
The server application can succesfully send the video stream with the following pipeline:
gst-launch-1.0 -vvv rtpbin name=rtpbin \
videotestsrc ! \
rtpgstpay ! application/x-rtp,media=application,payload=96,encoding-name=X-GST ! rtpbin.send_rtp_sink_0 \
rtpbin.send_rtp_src_0 ! udpsink port=5000 host=127.0.0.1 name=vrtpsink \
rtpbin.send_rtcp_src_0 ! udpsink port=5002 host=127.0.0.1 sync=false async=false name=vrtcpsink
The client pipeline looks like this:
gst-launch-1.0 -vvv rtpbin name=rtpbin \
udpsrc caps="application/x-rtp,payload=96,media=application,encoding-name=X-GST" port=5000 ! rtpbin.recv_rtp_sink_0 \
rtpbin. ! rtpgstdepay ! videoconvert ! autovideosink \
udpsrc port=5002 ! rtpbin.recv_rtcp_sink_0
rtpbin succesfully creates a sink and links to the udpsrc, but no stream comes out of rtp source pad.
The same pipeline without rtpbin can succesfully display the stream:
gst-launch-1.0 -vvv \
udpsrc caps="application/x-rtp,payload=96,media=application,encoding-name=X-GST" port=5000 ! \
rtpgstdepay ! videoconvert ! autovideosink
What an I doing wrong that rtpbin doesn't want to output the stream?
I also tried to replace the rtp_source part of the client with a fakesink to see if it would output anything, but still nothing comes out of rtpbin.
I found the solution to my problem. If any people come across the same problem, this is how to fix it:
First of all, rtpbin needs the clock-rate to be specified in the caps
When using rtpgst(de)pay, you need to specify the caps event string in your caps filter at the receiver, you can find this when printing the caps of the rtpgstpay element at the transmitter, eg:
application/x-rtp, media=(string)application, clock-rate=(int)90000, encoding-name=(string)X-GST, caps=(string)"dmlkZW8veC1yYXcsIGZvcm1hdD0oc3RyaW5nKUdSQVk4LCB3aWR0aD0oaW50KTY0MCwgaGVpZ2h0PShpbnQpNDYwLCBpbnRlcmxhY2UtbW9kZT0oc3RyaW5nKXByb2dyZXNzaXZlLCBwaXhlbC1hc3BlY3QtcmF0aW89KGZyYWN0aW9uKTEvMSwgY29sb3JpbWV0cnk9KHN0cmluZykxOjQ6MDowLCBmcmFtZXJhdGU9KGZyYWN0aW9uKTI1LzE\=", capsversion=(string)0, payload=(int)96, ssrc=(uint)2501988797, timestamp-offset=(uint)1970605309, seqnum-offset=(uint)2428, a-framerate=(string)25
So here the caps event string is
dmlkZW8veC1yYXcsIGZvcm1hdD0oc3RyaW5nKUdSQVk4LCB3aWR0aD0oaW50KTY0MCwgaGVpZ2h0PShpbnQpNDYwLCBpbnRlcmxhY2UtbW9kZT0oc3RyaW5nKXByb2dyZXNzaXZlLCBwaXhlbC1hc3BlY3QtcmF0aW89KGZyYWN0aW9uKTEvMSwgY29sb3JpbWV0cnk9KHN0cmluZykxOjQ6MDowLCBmcmFtZXJhdGU9KGZyYWN0aW9uKTI1LzE\=
When adding this to the caps at the receiver, you have to add a null terminator ( \0 ) at the end of the string.
Related
I have a third party application that reads data from a thermal camera and generates a RTP stream to a given UDP source. I am trying to wrap this RTP into a RTSP stream but I am running into problems...
The third party application basically runs gstreamer with this command
appsrc format=GST_FORMAT_TIME is-live=true block=true caps=video/x-raw,width=640,height=480,format=GRAY8,clock-rate=90000,framerate=10/1 ! openjpegenc ! rtpj2kpay ! udpsink host=127.0.0.1 port=3000
Using the command below I can visualize the stream on my machine
gst-launch-1.0 udpsrc port=3000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)JPEG2000, sampling=(string)GRAYSCALE, width=(int)640, height=(int)480, payload=(int)96" ! queue ! rtpj2kdepay ! openjpegdec ! videoconvert ! xvimagesink
However when trying to use the default RTP to RTSP application example using https://github.com/freedesktop/gstreamer-gst-rtsp-server/blob/master/examples/test-launch.c to just forward it with a RTSP container the connection fails with VLC. Command below:
./rtp-src-to-rtsp '( udpsrc port=3000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)JPEG2000, sampling=(string)GRAYSCALE, width=(int)640, height=(int)480, payload=(int)96" ! queue ! rtpj2kdepay ! rtpj2kpay )'
Any light on what I am doing wrong? VLC gives only a non-descriptive error
live555 error: Nothing to play for rtsp://{IP}:{PORT}/test
It might be a lack of support of J2K in VLC (I'm using revision 3.0.8-0).
Simulating your source with:
gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480,framerate=10/1,format=GRAY8 ! openjpegenc ! rtpj2kpay ! udpsink host=127.0.0.1 port=3000
and relaying as RSTP with:
./test-launch "udpsrc port=3000 auto-multicast=0 ! application/x-rtp,encoding-name=JPEG2000,sampling=GRAYSCALE ! queue ! rtpj2kdepay ! image/x-jpc ! jpeg2000parse ! rtpj2kpay name=pay0 "
works on Linux with X using:
gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp, encoding-name=JPEG2000,sampling=GRAYSCALE ! rtpj2kdepay ! jpeg2000parse ! openjpegdec ! videoconvert ! xvimagesink -v
Though, I haven't been able to receive with VLC, nor able to make a correct J2K/RTP SDP for VLC nor ffmpeg. Someone better skilled may further advise.
I have an issue in sending H264 streams to linphone.
When I play the following pipeline :
gst-launch-1.0 -v filesrc location=C:/ test.mp4 ! qtdemux ! avdec_h264 ! x264enc bitrate=192 ! rtph264pay ! udpsink host=127.0.0.1 port=9078
Everything is ok and the video played in linphone screen.
But what I want to do is to save first the video streams into a file then send this file to the linphone. What I did is the following:
Saving into a file
gst-launch-1.0 -v filesrc location=C:/ test.mp4 ! qtdemux ! avdec_h264 ! x264enc bitrate=192 ! filesink location=C: /videosample
Send to linphone:
gst-launch-1.0 -v filesrc location=C: /videosample ! h264parse ! rtph264pay ! udpsink host=127.0.0.1 port=9078
The packets received but the linphone played a black screen.
I want to know what I am missing in my pipelines or if there is a specific parameter to set.
Note that it is working when a play a gst receiver :
gst-launch-1.0 -v udpsrc port=9078 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! avdec_h264 ! autovideosink
I'm trying to use gstreamer to send a sample file .avi over a network. The code that I'm using to build my pipeline is the following:
gst-launch-1.0 -v rtpbin name=rtpbin latency=200 \
filesrc location=filesrc location=/home/enry/drop.avi ! decodebin name=dec \
dec. ! queue ! x264enc byte-stream=false bitrate=300 ! rtph264pay ! rtpbin.send_rtp_sink_0 \
rtpbin.send_rtp_src_0 ! udpsink port=5000 host=127.0.0.1 ts-offset=0 name=vrtpsink \
rtpbin.send_rtcp_src_0 ! udpsink port=5001 host=127.0.0.1 sync=false async=false \
name=vrtcpsink udpsrc port=5005 name=vrtpsrc ! rtpbin.recv_rtcp_sink_0
When I try to execute this command I'm getting this error:
gstavidemux.c(5383): gst_avi_demux_loop ():
/GstPipeline:pipeline0/GstDecodeBin:dec/GstAviDemux:avidemux0:
streaming stopped, reason not-linked
Execution ended after 0:00:00.032906515
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
Can you help me to solve this?
I think you would need a demux element before the decodebin, since an avi file would consist both an audio and video but you are using just one decodebin to decode them.
Take a look at the avidemux element here. You need it to get the video stream from the file.
Here is what I'm trying:
gst-launch -v udpsrc port=1234 ! fakesink dump=1
I test with:
gst-launch -v audiotestsrc ! udpsink host=127.0.0.1 port=1234
And everything works fine, I can see the packages arriving from the audiotestsrc
Now lets test with the webcam source:
gst-launch -v v4l2src device=/dev/video0 ! queue ! videoscale method=1 ! "video/x-raw-yuv,width=320,height=240" ! queue ! videorate ! "video/x-raw-yuv,framerate=(fraction)15/1" ! queue ! udpsink host=127.0.0.1 port=1234
And nothing happens, no package appears in the dump.
Here is a logdump of what verbose shows in the server.
Does anyone have a clue on this?
Try these (You may have to install gstreamer-ugly plugins for this one)
UDP streaming from Webcam (stream over the network)
gst-launch v4l2src device=/dev/video0 ! 'video/x-raw-yuv,width=640,height=480' ! x264enc pass=qual quantizer=20 tune=zerolatency ! rtph264pay ! udpsink host=127.0.0.1 port=1234
UDP Streaming received from webcam (receive over the network)
gst-launch udpsrc port=1234 ! "application/x-rtp, payload=127" ! rtph264depay ! ffdec_h264 ! xvimagesink sync=false
Update
To determine the payload at the streaming end simply use verbose option with gst-launch -v ...
Maybe packets are too large for udp? They are limited to 64K. Try resizing frames to really small size to check if this is the reason. If so, you may be interested in some compression and payloaders/depayloaders (gst-inspect | grep pay).
gstreamer1-1.16.0-1.fc30
gst-launch-1.0 -v filesrc location=/.../.../.../sample-mp4-file.mp4 ! qtdemux ! h264parse ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink port=8888 host=127.0.0.1
https://en.wikipedia.org/wiki/RTP_audio_video_profile
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