Gstreamer-Deepstream踩坑记录(个人记录持续更新)

1. 动态增删runtime add & delete

1.1 在删除资源时,官方给出的示例是以下代码:

        sinkpad = streammux.get_static_pad(pad_name)
        #Send flush stop event to the sink pad, then release from the streammux
        sinkpad.send_event(Gst.Event.new_flush_stop(False))
        streammux.release_request_pad(sinkpad)
        print("STATE CHANGE SUCCESS\n")
        #Remove the source bin from the pipeline
        pipeline.remove(g_source_bin_list[source_id])

然而使用这段代码,在复用sinkpad时会弹警告,经过查找原因是因为光release是不够的,因为Gstream底层是C,所以还得unref,然而python有自己的垃圾回收机制。stackoverflow上给出的解决方案是活用python机制,无需释放,下次继续使用。

1.2 添加RTSP资源时,除了管道初始化时添加的,后续添加均无反应。debug后发现添加RTSP类live-source时,没反应。原因可能是因为RTSP类的资源是异步async的,得在之后再手动地去设置一次source_bin的状态才可以。

1.3 在添加资源时报错

0:14:31.070358535  8691 0x7f3e180d3b00 ERROR                default gstrtspconnection.c:1046:gst_rtsp_connection_connect_with_response: failed to connect: Operation was cancelled
0:14:31.070372565  8691 0x7f3e180d3b00 ERROR                rtspsrc gstrtspsrc.c:5046:gst_rtsp_conninfo_connect:<source> Could not connect to server. (Generic error)
0:14:31.070380083  8691 0x7f3e180d3b00 WARN                 rtspsrc gstrtspsrc.c:7871:gst_rtspsrc_retrieve_sdp:<source> error: Failed to connect. (Generic error)
0:14:31.070399644  8691 0x7f3e180d3b00 WARN                 rtspsrc gstrtspsrc.c:7951:gst_rtspsrc_open:<source> can't get sdp
2023-04-14 08:57:49.032 error: gst-resource-error-quark: Could not open resource for reading and writing. (7): gstrtspsrc.c(7871): gst_rtspsrc_retrieve_sdp (): /GstPipeline:pipeline0/GstURIDecodeBin:source-bin-0/GstRTSPSrc:source:
Failed to connect. (Generic error)

找了很久问题,看了很多技术贴和讨论,大概方针是gstreamer的代码肯定是ok的,就要从其他地方debug。gstreamer开发者以前的回复是:大概是rtsp源是使用的udp发包,然后rtspsrc这个插件解决不了。当时帖子里面暂时的解决办法是把rtsp链接前缀改为rtspt,在本地尝试过后仍然不行。
英伟达论坛里官方技术支持提出的方案是尝试设置latency属性,也不行,pass。
最后在stackoverflow上面找到一个话题,链接,第一个方法,不行。然而第二个方法竟然神奇的管用了。虽然偶尔还是会出现错误,但是在少数几次尝试重连后是能够连上的。那么问题来了,这个ugly的插件到底是什么呢?

sudo apt-get remove gstreamer1.0-plugins-ugly

官方的解释

GStreamer Ugly Plug-ins is a set of plug-ins that have good quality and correct functionality, but distributing them might pose problems. The license on either the plug-ins or the supporting libraries might not be how we’d like. The code might be widely known to present patent problems.

和前面stackoverflow里面的回答一致,使用他们可能会带来一些身份验证,权限的问题。移除之后解决。


20230420更新
使用wireshark分析后发现是自己的宿主机主动发起的FIN请求。发现根本原因是自己程序逻辑是在报错后将其删除,而如何直接无视这个错误,uridecodebin待会自己是能连上的。。。因此直接无视这个错误就可以了。

2 各种报错

2.1 deepstream容器中cuda和numpy版本兼容性问题

from pycuda._driver import *

时报错:

RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe

ChatGPT给出的回答是:这个错误是由于你的 CUDA 驱动程序和 NumPy 库之间存在版本不兼容的问题。
既然之前代码能够正常跑,那么就卸载numpy尝试之前的各种版本,最后得到deepstream6.1/CUDA11.6正确对应版本

numpy                   1.23.4
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值