gstreamer - 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'" ")");
解决方案
我能够解决这个问题。单引号似乎没有成功转义。以下命令组合适用于 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 " ")");
推荐阅读
- c++ - Visual Studio 2017 在虚幻引擎 4 项目中显示 IntelliSense 错误
- r - shinyWidgets::verticalTabPanel() 不适用于 Shiny 模块
- java - Java LocalDateTime 模式
- python - 无法理解的解析器行为
- google-api - 如何在没有 oauth 的情况下使用谷歌日历 API 访问用户谷歌日历信息?
- python - 最新 Python 版本 3.8.2 的导入错误没有名为 tkinter 的模块问题
- macos - 如何在 Mac/UNIX 的 osascript 对话框中添加密码输入表单
- android - RecyclerView 项目宽度在迁移到视图绑定后变为 wrap_content
- c++ - 通过匹配键的子元素来查找地图中的任何元素
- c++ - 类语法问题