Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) dGPU 3070 ti laptop
• DeepStream Version 7.1
• JetPack Version (valid for Jetson only)
• TensorRT Version 10.12
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
I followed the steps for compiling python bindings with smart record enabled from DeepStream SDK FAQ - #41 by fanzh[nvurisrcbin plugin to perform smart recording in]
I then tried to replicate the test1 pipeline , but it starts the recording but never stops it> I am attaching my code and output.
Code:
nvurisrcbin = None
def stop_record_callback():
global nvurisrcbin
nvurisrcbin.emit('stop-sr', 0)
# keep same as native for get size of native struct
class SRUserContext(ctypes.Structure):
_fields_ = [
("sessionid", ctypes.c_int),
("name", ctypes.c_char * 32)
]
# GstElement * src, NvDsSRRecordingInfo* recordingInfo, void* data, void* user_data
def record_done(nvurisrcbin, recordingInfo, user_ctx, user_data):
print('******sr done*****')
print(f"record_done nvurisrcbin {nvurisrcbin} recordingInfo {recordingInfo}"
f" user_ctx {user_ctx} user_data {user_data}")
info = pyds.NvDsSRRecordingInfo.cast(hash(recordingInfo))
sr = pyds.SRUserContext.cast(hash(user_ctx))
print(f"filename {info.filename} -- dir {info.dirpath} {info.width} x {info.height}")
print(f"session id {sr.sessionid} -- name {sr.name}")
global nvurisrcbin
nvurisrcbin = Gst.ElementFactory.make("nvurisrcbin", "uri-decode-bin")
if not nvurisrcbin:
sys.stderr.write(" Unable to create nvurisrcbin \n")
nvurisrcbin.set_property("smart-record", 2) # enable smart record.
nvurisrcbin.set_property("smart-rec-dir-path", "./") # set record path.
# Create nvstreammux instance to form batches from one or more sources.
streammux = Gst.ElementFactory.make("nvstreammux", "Stream-muxer")
if not streammux:
sys.stderr.write(" Unable to create NvStreamMux \n")
nvurisrcbin.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
nvurisrcbin.connect("pad-added", cb_newpad, streammux)
nvurisrcbin.connect("sr-done", record_done, pipeline)
pipeline.set_state(Gst.State.PLAYING)
sessionid = pyds.get_native_ptr(pyds.alloc_buffer(4))
print(f"sessionid {sessionid}")
sr_user_context_size = ctypes.sizeof(SRUserContext)
sr_user_context_buf = pyds.get_native_ptr(pyds.alloc_buffer(sr_user_context_size))
sr_user_context = pyds.SRUserContext.cast(sr_user_context_buf)
sr_user_context.sessionid = 42
sr_user_context.name = "sr-demo"
print(f"sr_user_context_buf {sr_user_context_buf}")
# signal_info = GObject.signal_query('start-sr', nvurisrcbin)
# print(f"signal_info {signal_info.param_types}")
# stop smart record manually, optional
# GLib.timeout_add(5000, stop_record_callback)
def start_sr_function():
nvurisrcbin.emit('start-sr', sessionid, 2, 5, sr_user_context_buf)
print('******start sr*****')
return True
timer_id = GLib.timeout_add_seconds(10, start_sr_function)
try:
loop.run()
except:
pass
# cleanup
pipeline.set_state(Gst.State.NULL)
# release native memory
pyds.free_gbuffer(sessionid)
pyds.free_gbuffer(sr_user_context_buf)
Output:
⯠uv run test
Creating Pipeline
Is it Integrated GPU? : 0
Creating EGLSink
Playing file{clip}
Adding elements to Pipeline
Linking elements in the Pipeline
Starting pipeline
0:00:00.274042625 479665 0x210a9210 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:2092> [UID = 1]: deserialized trt engine from :/home/jagpreet/weapon_detection/model/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine
Implicit layer support has been deprecated
INFO: ../nvdsinfer/nvdsinfer_model_builder.cpp:327 [Implicit Engine Info]: layers num: 0
0:00:00.274084395 479665 0x210a9210 INFO nvinfer gstnvinfer.cpp:684:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2195> [UID = 1]: Use deserialized engine model: /home/jagpreet/weapon_detection/model/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine
0:00:00.281561824 479665 0x210a9210 INFO nvinfer gstnvinfer_impl.cpp:343:notifyLoadModelStatus:<primary-inference> [UID 1]: Load new model:test1_pgie.txt sucessfully
sessionid <capsule object NULL at 0x7a66477fd680>
sr_user_context_buf <capsule object NULL at 0x7a66477fd6b0>
Failed to query video capabilities: Invalid argument
In cb_newpad
gstname= video/x-raw
features= <Gst.CapsFeatures object at 0x7a66477cd610 (GstCapsFeatures at 0x7a65a4351050)>
******start sr*****
******start sr*****
******start sr*****
******start sr*****
******start sr*****
nvstreammux: Successfully handled EOS for source_id=0
End-of-stream