我正在尝试使用rtpbin示例 1.18.5运行Ubuntu21.10 VirtualBox VM。
从C代码中做任何事情看起来都很简单,但是rtpbin
示例使用了gst-launch-1.0
(在基本教程之一中介绍)。
我无法让rtpbin
示例在一开始运行时没有错误:
ffenc_h263
和ffdec_h263
(WARNING: erroneous pipeline: no element "ffenc_h263"
),所以我分别用avenc_h263
和avdec_h263
替换了它们v4l2src
正在寻找一种在/dev
中不可用的设备,所以我切换到了videotestsrc
。为了确保这些替换不成问题,我去掉了RTSP和UDP的内容,通过运行以下命令进行了检查:
gst-launch-1.0 videotestsrc ! videoconvert ! avenc_h263 ! rtph263pay \
! rtph263depay ! avdec_h263 ! xvimagesink
看了“酒吧”的视频。我也跑了
gst-launch-1.0 audiotestsrc ! amrnbenc ! rtpamrpay ! rtpamrdepay ! amrnbdec ! alsasink
听到了那烦人的测试语气。基于此,我认为问题在于UDP和RTSP。
正在运行
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
显示
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
然后在另一个窗口,我跑
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
并查看
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
显示:
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
确保所有的端口都正常工作
rtsp-test-server
和VLC安装rtsp-test-server
提供的端口上播放视频。我认为这不是一个完美的测试,因为TCP端口正在被使用而不是UDP,但是它很容易测试,所以我尝试了一下。但我没有看到任何视频也没有听到任何声音。有人能指出我的错误吗(S)?
发布于 2021-12-10 20:52:06
我几乎准备好提交我的问题,我又做了一次网上搜索。我找到了本教程,它显示了添加到udpsrc
和udpsink
元素中的几个额外标志。添加以下标志可以使示例工作,这样我就可以通过RTSP看到视频并听到声音:
host=127.0.0.1
元素上的udpsink
address=127.0.0.1
元素上的udpsource
我认为该教程中的其他标记可能是默认设置。
https://unix.stackexchange.com/questions/680984
复制相似问题