来自 rtspsrc gstreamer 的段错误

问题描述 投票:0回答:2

使用ubuntu、python和gstreamer抓取rtsp流时出现分段错误,导致无法查看rtsp流。使用 python 应用程序会导致 rtspsrc 出现分段错误,但使用 gst-launch 从终端运行 rtspsrc 是可行的。

在Python管道中将“rtspsrc”更改为testsrc,Python应用程序将按预期运行。在不同的硬件上使用 wsl/ubuntu 进行测试,python 应用程序运行正常。软件accel是配合wsl使用的,但是ubuntu需要运行在硬件accel上。

我的猜测是硬件驱动程序和在ubuntu机器上调用python程序之间存在一些驱动程序问题。我尝试过全新安装 ubuntu 22.04、ubuntu 服务器和 debian 11。所有结果都会导致分段错误。

在 WSL 上我仅运行 softwareaccel,但在 ubuntu 上我使用第 9 代 i7 运行 va-api。

使用 i965 驱动程序,因为它在使用 gst-launch 进行测试时给出了最佳结果。 通过编辑 bashrc 来选择驱动程序:

export LIBVA_DRIVER_NAME=i965
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri

Gstreamer 安装有:

apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav  gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio gstreamer1.0-vaapi

使用ubuntu-server,使用xorg和openbox来查看python应用程序。并且在pipeline中使用testsrc,查看成功。

Python 版本是 3.10(此 ubuntu 版本默认),已尝试过 3.8.17,但这导致了其他问题。

她是信息日志:

0:00:00.000072395  4020 0x55e10835cd60 INFO                GST_INIT gst.c:592:init_pre: Initializing GStreamer Core Library version 1.20.3
0:00:00.000137957  4020 0x55e10835cd60 INFO                GST_INIT gst.c:593:init_pre: Using library installed in /usr/lib/x86_64-linux-gnu
0:00:00.000169079  4020 0x55e10835cd60 INFO                GST_INIT gst.c:611:init_pre: Linux trd-lab 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64
0:00:00.000412160  4020 0x55e10835cd60 INFO                GST_INIT gstmessage.c:129:_priv_gst_message_initialize: init messages
0:00:00.000596636  4020 0x55e10835cd60 INFO                GST_INIT gstcontext.c:86:_priv_gst_context_initialize: init contexts
0:00:00.000782196  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:324:_priv_gst_plugin_initialize: registering 0 static plugins
0:00:00.000917477  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:232:gst_plugin_register_static: registered static plugin "staticelements"
0:00:00.000983365  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:234:gst_plugin_register_static: added static plugin "staticelements", result: 1
0:00:00.001037838  4020 0x55e10835cd60 INFO            GST_REGISTRY gstregistry.c:1827:ensure_current_registry: reading registry cache: /home/trd-lab/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.023222563  4020 0x55e10835cd60 INFO            GST_REGISTRY gstregistrybinary.c:683:priv_gst_registry_binary_read_cache: loaded /home/trd-lab/.cache/gstreamer-1.0/registry.x86_64.bin in 0.022142 seconds
0:00:00.023331369  4020 0x55e10835cd60 INFO            GST_REGISTRY gstregistry.c:1693:scan_and_update_registry: Validating plugins from registry cache: /home/trd-lab/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.023725663  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:1609:gst_plugin_ext_dep_extract_env_vars_paths:<plugin258> ignoring environment variable content 'i965': either not an absolute path or not a path at all
0:00:00.024335432  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:1609:gst_plugin_ext_dep_extract_env_vars_paths:<plugin259> ignoring environment variable content 'i965': either not an absolute path or not a path at all
0:00:00.024372573  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:1609:gst_plugin_ext_dep_extract_env_vars_paths:<plugin259> ignoring environment variable content '': either not an absolute path or not a path at all
0:00:00.024390041  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:1609:gst_plugin_ext_dep_extract_env_vars_paths:<plugin259> ignoring environment variable content '0': either not an absolute path or not a path at all
0:00:00.024917811  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:1609:gst_plugin_ext_dep_extract_env_vars_paths:<plugin260> ignoring environment variable content 'i965': either not an absolute path or not a path at all
0:00:00.025929544  4020 0x55e10835cd60 INFO            GST_REGISTRY gstregistry.c:1785:scan_and_update_registry: Registry cache has not changed
0:00:00.025959932  4020 0x55e10835cd60 INFO            GST_REGISTRY gstregistry.c:1862:ensure_current_registry: registry reading and updating done, result = 1
0:00:00.025976234  4020 0x55e10835cd60 INFO                GST_INIT gst.c:833:init_post: GLib runtime version: 2.72.4
0:00:00.025990409  4020 0x55e10835cd60 INFO                GST_INIT gst.c:835:init_post: GLib headers version: 2.72.1
0:00:00.026001625  4020 0x55e10835cd60 INFO                GST_INIT gst.c:837:init_post: initialized GStreamer successfully
0:00:00.031446448  4020 0x55e10835cd60 INFO            GST_PIPELINE gstparse.c:344:gst_parse_launch_full: parsing pipeline description 'rtspsrc location=rtsp://admin:[email protected]:554 ! decodebin ! videoconvert ! video/x-raw,format=BGR ! queue max-size-time=0 ! appsink name=sink sync=false'
0:00:00.035505134  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:987:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstrtsp.so" loaded
0:00:00.035547932  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "rtspsrc"
0:00:00.036989619  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:987:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstrealmedia.so" loaded
0:00:00.037025275  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "rtspreal"
0:00:00.038231949  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:987:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstasf.so" loaded
0:00:00.038266161  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "rtspwms"
0:00:00.039317883  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:987:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstplayback.so" loaded
0:00:00.039362963  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "decodebin"
0:00:00.040326337  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:987:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstcoreelements.so" loaded
0:00:00.040413330  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "typefind"
0:00:00.040496925  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstTypeFindElement@0x7fd9b8277200> adding pad 'sink'
0:00:00.040551395  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstTypeFindElement@0x7fd9b8277200> adding pad 'src'
0:00:00.040620028  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad typefind:sink
0:00:00.040706104  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2382:gst_pad_link_prepare: trying to link sink:proxypad0 and typefind:sink
0:00:00.040732918  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2590:gst_pad_link_full: linked sink:proxypad0 and typefind:sink, successful
0:00:00.040747625  4020 0x55e10835cd60 INFO               GST_EVENT gstevent.c:1660:gst_event_new_reconfigure: creating reconfigure event
0:00:00.040793763  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstDecodeBin@0x7fd9b8280110> adding pad 'sink'
0:00:00.041360023  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:987:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvideoconvert.so" loaded
0:00:00.041392494  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "videoconvert"
0:00:00.041796455  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstBaseTransform@0x7fd9b82982d0> adding pad 'sink'
0:00:00.041849087  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstBaseTransform@0x7fd9b82982d0> adding pad 'src'
0:00:00.041896458  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "queue"
0:00:00.042033002  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstQueue@0x7fd9b829a150> adding pad 'sink'
0:00:00.042071561  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstQueue@0x7fd9b829a150> adding pad 'src'
0:00:00.042844604  4020 0x55e10835cd60 INFO      GST_PLUGIN_LOADING gstplugin.c:987:_priv_gst_plugin_load_file_for_registry: plugin "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstapp.so" loaded
0:00:00.042890017  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "appsink"
0:00:00.043050929  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstBaseSink@0x7fd9b82a1100> adding pad 'sink'
0:00:00.043116416  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "pipeline"
0:00:00.043232351  4020 0x55e10835cd60 INFO            GST_PIPELINE gst/parse/grammar.y:683:gst_parse_perform_link: linking some pad of GstDecodeBin named decodebin0 to some pad of GstVideoConvert named videoconvert0 (0/0) with caps "(NULL)"
0:00:00.043275713  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstutils.c:1816:gst_element_link_pads_full: trying to link element decodebin0:(any) to element videoconvert0:(any)
0:00:00.043308967  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<videoconvert0:src> pad has no peer
0:00:00.043642633  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:1013:gst_element_get_static_pad: no such pad 'src_%u' in element "decodebin0"
0:00:00.043699326  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstutils.c:1270:gst_element_get_compatible_pad:<decodebin0> Could not find a compatible pad to link to videoconvert0:sink
0:00:00.043727106  4020 0x55e10835cd60 INFO                 default gstutils.c:2206:gst_element_link_pads_filtered: Could not link pads: decodebin0:(null) - videoconvert0:(null)
0:00:00.043779482  4020 0x55e10835cd60 INFO            GST_PIPELINE gst/parse/grammar.y:683:gst_parse_perform_link: linking some pad of GstVideoConvert named videoconvert0 to some pad of GstQueue named queue0 (0/0) with caps "video/x-raw, format=(string)BGR"
0:00:00.043818101  4020 0x55e10835cd60 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:489:gst_element_factory_create_with_properties: creating element "capsfilter"
0:00:00.043946492  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstBaseTransform@0x7fd9b82aa1e0> adding pad 'sink'
0:00:00.043987991  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:759:gst_element_add_pad:<GstBaseTransform@0x7fd9b82aa1e0> adding pad 'src'
0:00:00.044012028  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2069:gst_bin_get_state_func:<pipeline0> getting state
0:00:00.044046396  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<capsfilter0> completed state change to NULL
0:00:00.044084246  4020 0x55e10835cd60 INFO               GST_EVENT gstevent.c:1660:gst_event_new_reconfigure: creating reconfigure event
0:00:00.044112794  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstutils.c:1816:gst_element_link_pads_full: trying to link element videoconvert0:(any) to element capsfilter0:sink
0:00:00.044135442  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad capsfilter0:sink
0:00:00.044153994  4020 0x55e10835cd60 INFO                GST_PADS gstutils.c:1632:prepare_link_maybe_ghosting: videoconvert0 and capsfilter0 in same bin, no need for ghost pads
0:00:00.044183448  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2382:gst_pad_link_prepare: trying to link videoconvert0:src and capsfilter0:sink
0:00:00.044209574  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<videoconvert0:sink> pad has no peer
0:00:00.044498858  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<capsfilter0:src> pad has no peer
0:00:00.044558068  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2590:gst_pad_link_full: linked videoconvert0:src and capsfilter0:sink, successful
0:00:00.044582423  4020 0x55e10835cd60 INFO               GST_EVENT gstevent.c:1660:gst_event_new_reconfigure: creating reconfigure event
0:00:00.044598167  4020 0x55e10835cd60 INFO               GST_EVENT gstpad.c:5946:gst_pad_send_event_unchecked:<videoconvert0:src> Received event on flushing pad. Discarding
0:00:00.044647131  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstutils.c:1816:gst_element_link_pads_full: trying to link element capsfilter0:src to element queue0:(any)
0:00:00.044675414  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstelement.c:1016:gst_element_get_static_pad: found pad capsfilter0:src
0:00:00.044700377  4020 0x55e10835cd60 INFO                GST_PADS gstutils.c:1079:gst_pad_check_link: trying to link capsfilter0:src and queue0:sink
0:00:00.044722438  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<videoconvert0:sink> pad has no peer
0:00:00.044982180  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<queue0:src> pad has no peer
0:00:00.045023633  4020 0x55e10835cd60 INFO                GST_PADS gstutils.c:1632:prepare_link_maybe_ghosting: capsfilter0 and queue0 in same bin, no need for ghost pads
0:00:00.045047652  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2382:gst_pad_link_prepare: trying to link capsfilter0:src and queue0:sink
0:00:00.045137987  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<videoconvert0:sink> pad has no peer
0:00:00.045395433  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<queue0:src> pad has no peer
0:00:00.045433701  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2590:gst_pad_link_full: linked capsfilter0:src and queue0:sink, successful
0:00:00.045448492  4020 0x55e10835cd60 INFO               GST_EVENT gstevent.c:1660:gst_event_new_reconfigure: creating reconfigure event
0:00:00.045467983  4020 0x55e10835cd60 INFO               GST_EVENT gstpad.c:5946:gst_pad_send_event_unchecked:<capsfilter0:src> Received event on flushing pad. Discarding
0:00:00.045503445  4020 0x55e10835cd60 INFO            GST_PIPELINE gst/parse/grammar.y:683:gst_parse_perform_link: linking some pad of GstQueue named queue0 to some pad of GstAppSink named sink (0/0) with caps "(NULL)"
0:00:00.045534923  4020 0x55e10835cd60 INFO        GST_ELEMENT_PADS gstutils.c:1816:gst_element_link_pads_full: trying to link element queue0:(any) to element sink:(any)
0:00:00.045563731  4020 0x55e10835cd60 INFO                GST_PADS gstutils.c:1079:gst_pad_check_link: trying to link queue0:src and sink:sink
0:00:00.045585121  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<videoconvert0:sink> pad has no peer
0:00:00.045867653  4020 0x55e10835cd60 INFO                GST_PADS gstutils.c:1632:prepare_link_maybe_ghosting: queue0 and sink in same bin, no need for ghost pads
0:00:00.045912558  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2382:gst_pad_link_prepare: trying to link queue0:src and sink:sink
0:00:00.045935247  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<videoconvert0:sink> pad has no peer
0:00:00.046203279  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:2590:gst_pad_link_full: linked queue0:src and sink:sink, successful
0:00:00.046234223  4020 0x55e10835cd60 INFO               GST_EVENT gstevent.c:1660:gst_event_new_reconfigure: creating reconfigure event
0:00:00.046250500  4020 0x55e10835cd60 INFO               GST_EVENT gstpad.c:5946:gst_pad_send_event_unchecked:<queue0:src> Received event on flushing pad. Discarding
0:00:00.049251152  4020 0x55e10835cd60 INFO           GST_PARENTAGE gstbin.c:4377:gst_bin_get_by_name: [pipeline0]: looking up child element sink
0:00:00.050487825  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<sink> current NULL pending VOID_PENDING, desired next READY
0:00:00.050526840  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<sink> completed state change to READY
0:00:00.050546364  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<sink> notifying about state-changed NULL to READY (VOID_PENDING pending)
0:00:00.050585098  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'sink' changed state to 2(READY) successfully
0:00:00.050613782  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<queue0> current NULL pending VOID_PENDING, desired next READY
0:00:00.050637279  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<queue0> completed state change to READY
0:00:00.050654976  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<queue0> notifying about state-changed NULL to READY (VOID_PENDING pending)
0:00:00.050685421  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'queue0' changed state to 2(READY) successfully
0:00:00.050717996  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<capsfilter0> current NULL pending VOID_PENDING, desired next READY
0:00:00.050738271  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<capsfilter0> completed state change to READY
0:00:00.050759534  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<capsfilter0> notifying about state-changed NULL to READY (VOID_PENDING pending)
0:00:00.050782771  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'capsfilter0' changed state to 2(READY) successfully
0:00:00.050806604  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<videoconvert0> current NULL pending VOID_PENDING, desired next READY
0:00:00.050823603  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<videoconvert0> completed state change to READY
0:00:00.050838897  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<videoconvert0> notifying about state-changed NULL to READY (VOID_PENDING pending)
0:00:00.050861696  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'videoconvert0' changed state to 2(READY) successfully
0:00:00.050880887  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<decodebin0> current NULL pending VOID_PENDING, desired next READY
0:00:00.050917815  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<typefind> current NULL pending VOID_PENDING, desired next READY
0:00:00.050942266  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<typefind> completed state change to READY
0:00:00.050957651  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<typefind> notifying about state-changed NULL to READY (VOID_PENDING pending)
0:00:00.050979669  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<decodebin0> child 'typefind' changed state to 2(READY) successfully
0:00:00.051000703  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<decodebin0> completed state change to READY
0:00:00.051018876  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<decodebin0> notifying about state-changed NULL to READY (VOID_PENDING pending)
0:00:00.051045533  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'decodebin0' changed state to 2(READY) successfully
0:00:00.051069788  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<rtspsrc0> current NULL pending VOID_PENDING, desired next READY
0:00:00.051119799  4020 0x55e10835cd60 INFO                    task gsttask.c:516:gst_task_set_lock: setting stream lock 0x7fd9b82749a8 on task 0x7fd9b8289170
0:00:00.051146928  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<rtspsrc0> completed state change to READY
0:00:00.051163604  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<rtspsrc0> notifying about state-changed NULL to READY (VOID_PENDING pending)
0:00:00.051250387  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'rtspsrc0' changed state to 2(READY) successfully
0:00:00.051303535  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2778:gst_element_continue_state:<pipeline0> committing state from NULL to READY, pending PLAYING, next PAUSED
0:00:00.051327448  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<pipeline0> notifying about state-changed NULL to READY (PLAYING pending)
0:00:00.051349063  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2786:gst_element_continue_state:<pipeline0> continue state change READY to PAUSED, final PLAYING
0:00:00.051382586  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<sink> current READY pending VOID_PENDING, desired next PAUSED
0:00:00.051417338  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2935:gst_bin_change_state_func:<pipeline0> child 'sink' is changing state asynchronously to PAUSED
0:00:00.051459914  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<queue0> current READY pending VOID_PENDING, desired next PAUSED
0:00:00.051491613  4020 0x55e10835cd60 INFO                    task gsttask.c:516:gst_task_set_lock: setting stream lock 0x7fd9b8286de0 on task 0x7fd9b8289290
0:00:00.051514700  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:6291:gst_pad_start_task:<queue0:src> created task 0x7fd9b8289290
0:00:00.051624433  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<queue0> completed state change to PAUSED
0:00:00.051652490  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<queue0> notifying about state-changed READY to PAUSED (VOID_PENDING pending)
0:00:00.051681563  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'queue0' changed state to 3(PAUSED) successfully
0:00:00.051709033  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<capsfilter0> current READY pending VOID_PENDING, desired next PAUSED
0:00:00.051787820  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<capsfilter0> completed state change to PAUSED
0:00:00.051812036  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<capsfilter0> notifying about state-changed READY to PAUSED (VOID_PENDING pending)
0:00:00.051837549  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'capsfilter0' changed state to 3(PAUSED) successfully
0:00:00.051862610  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<videoconvert0> current READY pending VOID_PENDING, desired next PAUSED
0:00:00.051904986  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<videoconvert0> completed state change to PAUSED
0:00:00.051935627  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<videoconvert0> notifying about state-changed READY to PAUSED (VOID_PENDING pending)
0:00:00.051963621  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'videoconvert0' changed state to 3(PAUSED) successfully
0:00:00.051990544  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<decodebin0> current READY pending VOID_PENDING, desired next PAUSED
0:00:00.052057274  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<typefind> current READY pending VOID_PENDING, desired next PAUSED
0:00:00.052094913  4020 0x55e10835cd60 INFO                GST_PADS gstpad.c:4357:gst_pad_peer_query:<decodebin0:sink> pad has no peer
0:00:00.052141093  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<typefind> completed state change to PAUSED
0:00:00.052166744  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<typefind> notifying about state-changed READY to PAUSED (VOID_PENDING pending)
0:00:00.052202665  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<decodebin0> child 'typefind' changed state to 3(PAUSED) successfully
0:00:00.052235005  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2935:gst_bin_change_state_func:<pipeline0> child 'decodebin0' is changing state asynchronously to PAUSED
0:00:00.052286404  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<rtspsrc0> current READY pending VOID_PENDING, desired next PAUSED
0:00:00.052377606  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<rtspsrc0> completed state change to PAUSED
0:00:00.052403265  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<rtspsrc0> notifying about state-changed READY to PAUSED (VOID_PENDING pending)
0:00:00.052451368  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2971:gst_bin_change_state_func:<pipeline0> child 'rtspsrc0' changed state to 3(PAUSED) successfully without preroll
0:00:00.052544729  4020 0x55e10835cd60 INFO                pipeline gstpipeline.c:533:gst_pipeline_change_state:<pipeline0> pipeline is live

(... could not succeed 30k characters and had to remove some..)

0:00:00.053293818  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<videoconvert0> completed state change to PLAYING
0:00:00.053345812  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<videoconvert0> notifying about state-changed PAUSED to PLAYING (VOID_PENDING pending)
0:00:00.053378590  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'videoconvert0' changed state to 4(PLAYING) successfully
0:00:00.053634551  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2479:gst_bin_element_set_state:<decodebin0> current READY pending PAUSED, desired next PLAYING
0:00:00.053663779  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2935:gst_bin_change_state_func:<pipeline0> child 'decodebin0' is changing state asynchronously to PLAYING
0:00:00.053700351  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2806:gst_element_continue_state:<rtspsrc0> completed state change to PLAYING
0:00:00.053717369  4020 0x55e10835cd60 INFO              GST_STATES gstelement.c:2706:_priv_gst_element_state_changed:<rtspsrc0> notifying about state-changed PAUSED to PLAYING (VOID_PENDING pending)
0:00:00.053744787  4020 0x55e10835cd60 INFO              GST_STATES gstbin.c:2928:gst_bin_change_state_func:<pipeline0> child 'rtspsrc0' changed state to 4(PLAYING) successfully
Segmentation fault (core dumped)
python segmentation-fault gstreamer rtsp ubuntu-22.04
2个回答
0
投票

Rtspsrc 需要动态 pad 处理,命令行应用程序会自动执行此操作,但 python 不会。 Rtspsrc pads 在运行时创建,这意味着它们需要在运行时链接。这通常通过“pad-added”信号的

on_pad_added()
回调函数来完成。我这里有一个简单的例子:

# Connect dynamic pads to rtph264, otherwise will get not linked error
rtspsrc.connect("pad-added", self.on_pad_added, rtph264depay)

还有

on_pad_added()
功能:

def on_pad_added(self, src: Gst.Element, pad: Gst.Pad, target: Gst.Element):
    """Callback function to connect the dynamic pads of the elements"""
    sink_pad: Gst.Pad = self.get_static_pad(target, "sink")
    if not sink_pad.is_linked():
        pad.link(sink_pad)
        logger.info(f"Linked {src.name} to {target.name}")

0
投票

通过确保 gstreamer 是第一个被调用的库,问题自行解决。不知道为什么,但它有效。 在 ubuntu、ubuntu 服务器和 debian 上进行了测试。使用 WSL,库的顺序并不重要。

import gi
gi.require_version('Gst', '1.0')
gi.require_version("GstApp","1.0")
from gi.repository import Gst, GLib, GstApp
_ = GstApp

from collections import deque

...
© www.soinside.com 2019 - 2024. All rights reserved.