deepstream读取mp4文件及不同类型视频输入bug解决

在deepstream中使用mp4文件,与rtsp类似,使用uridecodebin即可,(可见官方test.py文件)

def create_source_bin(index, uri):
    print("Creating source bin")

    # Create a source GstBin to abstract this bin's content from the rest of the
    # pipeline
    bin_name = "source-bin-%02d" % index
    print(bin_name)
    nbin = Gst.Bin.new(bin_name)
    if not nbin:
        sys.stderr.write(" Unable to create source bin \n")

    # Source element for reading from the uri.
    # We will use decodebin and let it figure out the container format of the
    # stream and the codec and plug the appropriate demux and decode plugins.
    uri_decode_bin = Gst.ElementFactory.make("uridecodebin", "uri-decode-bin")
    if not uri_decode_bin:
        sys.stderr.write(" Unable to create uri decode bin \n")
    # We set the input uri to the source element
    uri_decode_bin.set_property("uri", uri)
    # Connect to the "pad-added" signal of the decodebin which generates a
    # callback once a new pad for raw data has beed created by the decodebin
    uri_decode_bin.connect("pad-added", cb_newpad, nbin)
    uri_decode_bin.connect("child-added", decodebin_child_added, nbin)

    # We need to create a ghost pad for the source bin which will act as a proxy
    # for the video decoder src pad. The ghost pad will not have a target right
    # now. Once the decode bin creates the video decoder and generates the
    # cb_newpad callback, we will set the ghost pad target to the video decoder
    # src pad.
    Gst.Bin.add(nbin, uri_decode_bin)
    bin_pad = nbin.add_pad(
        Gst.GhostPad.new_no_target(
            "src", Gst.PadDirection.SRC))
    if not bin_pad:
        sys.stderr.write(" Failed to add ghost pad in source bin \n")
        return None
    return nbin

1、错误:

Error: gst-resource-error-quark: Invalid URI “/home/打码/打码.mp4”. (3): gsturidecodebin.c(1383): gen_source_element (): /GstPipeline:pipeline0/GstBin:source-bin-03/GstURIDecodeBin:uri-decode-bin

解决方案:
如果是文件系统中的mp4文件,记得加上file://前缀,如将输入设为file:///home/打码/打码.mp4。

2.错误:

Error: gst-stream-error-quark: memory type configured and i/p buffer mismatch ip_surf 2 muxer 3 (1): gstnvstreammux.c(643): gst_nvstreammux_chain (): /GstPipeline:pipeline0/GstNvStreamMux:Stream-muxer

解决方案:
不同类型的输入(如rtsp流和mp4文件)会产生不同的内存类型,为了解决这个问题需要保证连接到streammux的输入产生相同的内存类型(即都是ftsp或者都是mp4)。或者,也可以找到下面的代码:

streammux.set_property("nvbuf-memory-type", mem_type)

将其注释掉即可。

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-13 05:50:01       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-13 05:50:01       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-13 05:50:01       58 阅读
  4. Python语言-面向对象

    2024-07-13 05:50:01       69 阅读

热门阅读

  1. samout 结构再优化 收敛速度再加快

    2024-07-13 05:50:01       25 阅读
  2. 延时订单的实现

    2024-07-13 05:50:01       28 阅读
  3. 数学基础 -- 三角学

    2024-07-13 05:50:01       27 阅读
  4. 07-7.5.2 散列函数的构造

    2024-07-13 05:50:01       27 阅读
  5. React vs Vue:谁是前端界的冠军?

    2024-07-13 05:50:01       24 阅读
  6. [NeetCode 150] Longest Consecutive Sequence

    2024-07-13 05:50:01       21 阅读
  7. sqlserver设置端口

    2024-07-13 05:50:01       22 阅读
  8. C++:using重新定义继承时访问权限

    2024-07-13 05:50:01       29 阅读
  9. git列出提交记录的文件路径

    2024-07-13 05:50:01       23 阅读
  10. 关于对于短视频的认识-复盘与再次复盘

    2024-07-13 05:50:01       23 阅读
  11. sqlalchemy反射视图

    2024-07-13 05:50:01       21 阅读
  12. vue 组件里面的方法修改外面的数据

    2024-07-13 05:50:01       25 阅读
  13. 使用Trie树高亮关键词

    2024-07-13 05:50:01       25 阅读
  14. qt 的布局

    2024-07-13 05:50:01       29 阅读
  15. 《每天十分钟》-红宝书第4版-函数

    2024-07-13 05:50:01       23 阅读
  16. 【Scrapy】Scrapy 中间件等级设置规则

    2024-07-13 05:50:01       25 阅读