使用 gstreamer 接收 RTP 流

Receive RTP stream with gstreamer

我正在尝试使用 gstreamer 从基于 linux 的微控制器流式传输到 python 脚本。这是为了解决微控制器上无法使用 opencv/python.

直接打开相机的一些固件问题

gstreamer 的启动输出命令如下所示:

gst-launch-1.0 -e -v v4l2src device=/dev/video0  ! video/x-raw,format=UYVY,width=1280,height=720,framerate=30/1 ! videoconvert ! video/x-raw,width=1280,height=720,framerate=30/1 ! avenc_mpeg4 bitrate=4000000 ! rtpmp4vpay config-interval=1 ! udpsink host="" port=5004

我的问题是,“接收”命令会是什么样子?目前它正在使用这个:

gst-launch-1.0 udpsrc port=5004 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP4" ! rtpmp4vdepay ! glimagesink 

但这会引发错误:

WARNING: erroneous pipeline: could not link udpsrc0 to rtpmp4vdepay0

我好像遗漏了什么....关于如何正确编写接收脚本的文档不多。最终,我会在 python 中加入类似这样的内容:

cap_receive = cv2.VideoCapture('gstreamer receive command script goes here' , cv2.CAP_GSTREAMER)

非常感谢任何见解,TIA!

如果您检查 gst-inspect-1.0 rtpmp4vdepay 的输出,您会注意到水槽垫的以下盖子:

  SINK template: 'sink'
    Availability: Always
    Capabilities:
      application/x-rtp
                  media: video
             clock-rate: [ 1, 2147483647 ]
          encoding-name: MP4V-ES

您会注意到 encoding-name 实际上是 MP4V-ES

最重要的是 - 您不能将 RTP 解包器直接连接到图像接收器。在此之前,您必须进行解析、解码和颜色转换。如果您想手动构建管道,也许 decodebin 可以在这里帮助您..