首页 > 解决方案 > gstreamer gst-rtsp-server 是否接受 udpsrc (RTP)?

问题描述

我想将 RTP 流输入到 gstreamer gst-rtsp-server。对于初始测试,我使用来自 github (版本 1.14)的test-launch.c 示例。

当我编译并使用它时,它与默认示例一起工作得很好,它按预期工作,我可以在 rtsp://127.0.0.1:8554/test 看到一个流(例如使用 vlc 播放器):

./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"

但是如果我提供一个 RTP udp 流使用

  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

我使用 test-launch 示例在此端口上使用 udpsrc 播放此流

./test-launch "( udpsrc port=5000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! rtph264pay name=pay0 )"

没有可用的 rtsp 流。gst_rtsp_media_factory_set_launch当以像后者这样的方式提出时,我这边是否有任何问题或误解?

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'" ")");

标签: gstreamerrtsp

解决方案


我能够解决这个问题。单引号似乎没有成功转义。以下命令组合适用于 test-launch 示例。

从连接到 /dev/video0 的摄像头提供 RTP udp 流

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

使用带有(转义)双引号的测试启动示例

./test-launch "( udpsrc port=5000 caps=\"application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264\" ! rtph264depay ! rtph264pay name=pay0 )"

在 rtsp://127.0.0.1:8554/test 准备好流

使用 gstreamer 打开 rtsp 流(也可以由 vlc 播放器完成)

gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test uridecodebin0::source::latency=1000

因此,启动这种管道的正确 c 代码行将是

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 " ")");

推荐阅读