有4路rtsp流,在运行1个小时左右会出现画面卡死,使用python,经过GST_DEBUG=3运行python程序到画面卡死时会出现此错误。
There are 4 RTSP streams, and after running for about an hour, the video freezes. When running the Python program with GST_DEBUG=3
, the following error occurs at the moment the video freezes.
1:24:45.476183904 3446 0xaaab0e2e2c70 WARN nvurisrcbin gstdsnvurisrcbin.cpp:1412:watch_source_status:<uri-decode-bin> warning: No data from source since last 3 sec. Trying reconnection
它仅仅出现了这一处没有进行后续尝试重新连接的输出。经过vlc测试rtsp流是正常的。
在uri_decode_bin中使用了smart record记录原始视频,同时pipeline中使用了 splitMuxSink来记录推理后的视频。我不确定是否与这两项有关,但当我注释掉关于smart record与 splitMuxSink相关代码后,运行了3个小时左右才会出现画面卡死问题。
It only produced this single output without attempting to reconnect afterward. Testing with VLC confirmed that the RTSP streams are functioning normally.
In the uri_decode_bin
, smart record
is used to save the original video, while splitMuxSink
is used in the pipeline to record the post-inference video. I’m not certain if these two components are related to the issue, but when I commented out the code related to smart record
and splitMuxSink
, the video freezing problem occurred after approximately 3 hours of runtime.
This suggests that the smart record
and splitMuxSink
functionalities might be contributing to the issue, potentially due to resource exhaustion, file handling, or pipeline complexity. Further investigation into these components, such as monitoring resource usage (e.g., memory, CPU, file handles) and checking for errors in their implementation, could help identify the root cause.
以下是关于uri_decode_bin部分的代码:
Here is the code related to the uri_decode_bin
part:
def create_source_bin(index, Gst, uri, outputPath):
# Create a source GstBin to abstract this bin's content from the rest of the
# pipeline
bin_name = "source-bin-%02d" % index
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")
uri_decode_bin = Gst.ElementFactory.make("nvurisrcbin", "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)
# 自动重连,数字是间隔秒数
uri_decode_bin.set_property("rtsp-reconnect-interval", 3)
# smart record
uri_decode_bin.set_property("smart-record", 2)
uri_decode_bin.set_property("smart-rec-dir-path", outputPath)
uri_decode_bin.set_property("smart-rec-file-prefix", "original_")
# 如果自动停止后立即开始录制,那么会导致不能正常录制。
uri_decode_bin.set_property("smart-rec-default-duration", 119)
# 每个通道间隔2秒,防止出现录像有间隔导致有部分录像不能被完整记录
t = threading.Timer(10+index*2, action, args=[uri_decode_bin])
t.start()
# 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, uri_decode_bin
def action(ele):
a = pyds.alloc_buffer1(4)
ele.emit('start-sr', a, 2, 600, None)
# 连续录制,每段2分钟
t = threading.Timer(120, action, args=[ele])
t.start()
请问该如何解决?
How can I solve this problem?