2

I would like to stream with rtsp using GStreamer pipeline elements. First, I checked with gst-inspect-1.0 that rtspclientsink is available:

xilinx-k26-starterkit-2020_2:/# gst-inspect-1.0 | grep rtsp
rtspclientsink:  rtspclientsink: RTSP RECORD client
rtsp:  rtspsrc: RTSP packet receiver
rtsp:  rtpdec: RTP Decoder

Then, wrote simplest pipeline and tested it with videotestsrc as source and kmssink as the sink. Following pipeline works well:

gst-launch-1.0 videotestsrc ! video/x-raw, width=1920, height=1080 ! kmssink bus-id=fd4a0000.zynqmp-display fullscreen-overlay=1 sync=false

Then, changed sink to rtspclientsink:

gst-launch-1.0 videotestsrc ! video/x-raw, width=1920, height=1080 !  rtspclientsink location=rtsp://localhost:554/test

However, even with a simple pipeline, stream could not be started and encountered with the error:

xilinx-k26-starterkit-2020_2:/# gst-launch-1.0 videotestsrc ! video/x-raw, width=1920,height=1080 ! rtspclientsink location=rtsp://localhost:554/test
Setting pipeline to PAUSED ...
Pipeline is PREROLLED ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://localhost:554/test
ERROR: from element /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Could     not open resource for reading and writing.
Additional debug info:
../../../gst-rtsp-server-1.16.1/gst/rtsp-sink/gstrtspclientsink.c(3236):     gst_rtsp_client_sink_connect_to_server (): /GstPipeline:pipeline0    /GstRTSPClientSink:rtspclientsink0:
Failed to connect. (Generic error)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Could anyone enlighten me about the error and the way I can use rtspclientsink as a sink? I also considered to stream with a script (given below) which uses rtsp server as follows but I wonder is it possible to use rtspclientsink as an pipeline element.Thanks.

#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#define DEFAULT_RTSP_PORT "9001"
...(some code)
/* create a server instance */
server = gst_rtsp_server_new ();
g_object_set (server, "service", port, NULL);
mounts = gst_rtsp_server_get_mount_points (server);

factory = gst_rtsp_media_factory_new ();
gst_rtsp_media_factory_set_launch (factory, argv[1]);
gst_rtsp_media_factory_set_shared (factory, TRUE);
...(some code that creates pipeline and calls rtsp stream function)
Alperen
  • 21
  • 1
  • 3
  • Found an rtspclientsink example at https://stackoverflow.com/a/47088647/16748533. *gst-launch-1.0 videotestsrc ! queue ! x264enc ! rtspclientsink location=rtsp://127.0.0.1:8554/test* tested and encountered with the same error: 'ERROR: from element /GstPipeline:pipeline0/GstRTSPClientSink:rtspclientsink0: Could not open resource for reading and writing.' – Alperen Sep 08 '21 at 07:33
  • did you end up finding a solution for this ? I'm at the same point. I have a feeling that besides starting the pipeline you also need to start a rtsp-server application.. but i'm not sure as i can't find any documentation on how to use it – clogwog Jul 08 '22 at 03:53

1 Answers1

4

download rtsp-simple server from

https://github.com/aler9/rtsp-simple-server/releases

unzip and run it

tar xvf rtsp-simple-server_v0.19.3_linux_amd64.tar.gz
./rtsp-simple-server

it will tell you what port it's listening on

2022/07/31 13:23:34 INF rtsp-simple-server v0.19.3
2022/07/31 13:23:34 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2022/07/31 13:23:34 INF [RTMP] listener opened on :1935
2022/07/31 13:23:34 INF [HLS] listener opened on :8888

point your rtsp stream at it (change localhost to the server hosting the rtsp-simple-server if you are sending over network)

gst-launch-1.0 -v videotestsrc ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! x264enc speed-preset=veryfast tune=zerolatency bitrate=800 ! rtspclientsink location=rtsp://localhost:8554/mystream

Check rtsp-simple-server console log

2022/07/31 13:26:02 INF [RTSP] [conn 192.168.1.130:34932] opened
2022/07/31 13:26:02 INF [RTSP] [session 247376253] created by 192.168.1.130:34932
2022/07/31 13:26:03 INF [RTSP] [session 247376253] is publishing to path 'mystream', 1 track with UDP

open vlc-player -> Media -> Open Network Stream

enter image description here

Press Play

vlc should show a test pattern

you will see below in rtsp-simple-server console log

2022/07/31 13:27:10 INF [RTSP] [conn 127.0.0.1:53900] opened
2022/07/31 13:27:10 INF [RTSP] [session 749381985] created by 127.0.0.1:53900
2022/07/31 13:27:10 INF [RTSP] [session 749381985] is reading from path 'mystream', 1 track with UDP

Duane
  • 4,572
  • 6
  • 32
  • 33