问题
I want to input an RTP stream into a gstreamer gst-rtsp-server. For initial tests I use the test-launch.c example from github (version 1.14).
When I compile it and use it, it works well with the default example it works as expected and I can see a stream (for example using vlc player) at rtsp://127.0.0.1:8554/test:
./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"
But if I provide an RTP udp stream using
gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=720 ! x264enc ! video/x-h264, stream-format=byte-stream ! rtph264pay ! udpsink host=127.0.0.1 port=5000
and I use the test-launch example to play this stream using udpsrc on this port using
./test-launch "( udpsrc port=5000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! rtph264pay name=pay0 )"
there is no rtsp stream available. Is there any issue or misconception from my side with gst_rtsp_media_factory_set_launch, when put it up in a way like the latter?
gst_rtsp_media_factory_set_launch (factory, "( "
"udpsrc port=5000 "
"caps='application/x-rtp, media=(string)video, "
"clock-rate=(int)90000, encoding-name=(string)H264'" ")");
回答1:
I was able to solve the problem. The single quotes seem not to be escaped successfully . The following combination of command works with the test-launch example.
Provide RTP udp stream from a camera connected to /dev/video0
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! videoscale ! "video/x-raw,is-live=true,latency=0" ! x264enc ! "video/x-h264" ! rtph264pay name=pay0 pt=96 ! udpsink host=127.0.0.1 port=5000 sync=false
Use the test-launch example with (escaped) double quotes
./test-launch "( udpsrc port=5000 caps=\"application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264\" ! rtph264depay ! rtph264pay name=pay0 )"
stream ready at rtsp://127.0.0.1:8554/test
Open the rtsp stream using gstreamer (which might also be done by vlc player)
gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test uridecodebin0::source::latency=1000
Accordingly a correct line of c-code to launch this kind of pipeline would be
gst_rtsp_media_factory_set_launch (factory, "( "
"udpsrc port=5600 "
"caps = \"application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264\" ! "
"rtph264depay ! rtph264pay name=pay0 " ")");
来源:https://stackoverflow.com/questions/65203969/does-gstreamer-gst-rtsp-server-accept-udpsrc-rtp