首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么来自Gstreamer的rtpbin示例不起作用?

为什么来自Gstreamer的rtpbin示例不起作用?
EN

Unix & Linux用户
提问于 2021-12-10 20:52:06
回答 1查看 984关注 0票数 0

我正在尝试使用rtpbin示例 1.18.5运行Ubuntu21.10 VirtualBox VM。

从C代码中做任何事情看起来都很简单,但是rtpbin示例使用了gst-launch-1.0 (在基本教程之一中介绍)。

我无法让rtpbin示例在一开始运行时没有错误:

  • ffenc_h263ffdec_h263 (WARNING: erroneous pipeline: no element "ffenc_h263"),所以我分别用avenc_h263avdec_h263替换了它们
  • v4l2src正在寻找一种在/dev中不可用的设备,所以我切换到了videotestsrc

为了确保这些替换不成问题,我去掉了RTSP和UDP的内容,通过运行以下命令进行了检查:

代码语言:javascript
运行
复制
gst-launch-1.0 videotestsrc ! videoconvert ! avenc_h263 ! rtph263pay \ 
    ! rtph263depay ! avdec_h263 ! xvimagesink

看了“酒吧”的视频。我也跑了

代码语言:javascript
运行
复制
gst-launch-1.0 audiotestsrc ! amrnbenc ! rtpamrpay ! rtpamrdepay ! amrnbdec ! alsasink

听到了那烦人的测试语气。基于此,我认为问题在于UDP和RTSP。

正在运行

代码语言:javascript
运行
复制
 gst-launch-1.0 rtpbin name=rtpbin \
         videotestsrc ! videoconvert ! avenc_h263 ! rtph263pay ! rtpbin.send_rtp_sink_0 \
                   rtpbin.send_rtp_src_0 ! udpsink port=5000                            \
                   rtpbin.send_rtcp_src_0 ! udpsink port=5001 sync=false async=false    \
                   udpsrc port=5005 ! rtpbin.recv_rtcp_sink_0                           \
         audiotestsrc ! amrnbenc ! rtpamrpay ! rtpbin.send_rtp_sink_1                   \
                   rtpbin.send_rtp_src_1 ! udpsink port=5002                            \
                   rtpbin.send_rtcp_src_1 ! udpsink port=5003 sync=false async=false    \
                   udpsrc port=5007 ! rtpbin.recv_rtcp_sink_1

显示

代码语言:javascript
运行
复制
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:59.0 / 99:99:99 # This is counting up

然后在另一个窗口,我跑

代码语言:javascript
运行
复制
gst-launch-1.0 rtpbin name=rtpbin                                          \
     udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1996" \
             port=5000 ! rtpbin.recv_rtp_sink_0                                \
         rtpbin. ! rtph263depay ! avdec_h263 ! xvimagesink                    \
      udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0                               \
      rtpbin.send_rtcp_src_0 ! udpsink port=5005 sync=false async=false        \
     udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)AMR,encoding-params=(string)1,octet-align=(string)1" \
             port=5002 ! rtpbin.recv_rtp_sink_1                                \
         rtpbin. ! rtpamrdepay ! amrnbdec ! alsasink                           \
      udpsrc port=5003 ! rtpbin.recv_rtcp_sink_1                               \
      rtpbin.send_rtcp_src_1 ! udpsink port=5007 sync=false async=false

并查看

代码语言:javascript
运行
复制
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

我希望看到一些UDP端口打开(5000、5001、5002、5003、5005和5007)。当然,运行netstat显示:

代码语言:javascript
运行
复制
rtsp@rtsp-VirtualBox:~$ sudo netstat -apn | grep -w 500[0-9]
udp        0      0 0.0.0.0:5000            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5001            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5002            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5003            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5005            0.0.0.0:*                           6862/gst-launch-1.0 
udp        0      0 0.0.0.0:5007            0.0.0.0:*                           6862/gst-launch-1.0 

确保所有的端口都正常工作

  • 我从snap rtsp-test-server和VLC安装
  • 我能够在rtsp-test-server提供的端口上播放视频。我认为这不是一个完美的测试,因为TCP端口正在被使用而不是UDP,但是它很容易测试,所以我尝试了一下。

但我没有看到任何视频也没有听到任何声音。有人能指出我的错误吗(S)?

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2021-12-10 20:52:06

我几乎准备好提交我的问题,我又做了一次网上搜索。我找到了本教程,它显示了添加到udpsrcudpsink元素中的几个额外标志。添加以下标志可以使示例工作,这样我就可以通过RTSP看到视频并听到声音:

  • 所有host=127.0.0.1元素上的udpsink
  • 所有address=127.0.0.1元素上的udpsource

我认为该教程中的其他标记可能是默认设置。

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/680984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档