Nvidia DS smart recording callback is not working

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
Jetson Orin NX
• DeepStream Version
7.1
• JetPack Version (valid for Jetson only)
6.2
• Issue Type( questions, new requirements, bugs)
Question

Hello I’m using NVDS Smart Recording in my custom deep stream project and creating my contexts per source as such before pipeline starts, I also link them to the
“”"
NvDsSRInitParams sr_params = {0};
sr_params.containerType = NVDSSR_CONTAINER_MP4;
sr_params.cacheSize = 30;
sr_params.defaultDuration = 10;
sr_params.callback = smart_record_callback;
gchar *unique_prefix = generate_unique_filename();
sr_params.fileNamePrefix = unique_prefix;
if (NvDsSRCreate(&smart_record_ctx[source_id], &sr_params) !=
NVDSSR_STATUS_OK) {
g_printerr(“[preallocate_demux_outputs] Failed to create SR ctx for src %u\n”,
source_id);
g_free(unique_prefix);
return false;
}
g_free(unique_prefix);


GstElement *queue_sr = gst_element_factory_make(“queue”, NULL);
GstElement *capsfilter_sr = gst_element_factory_make(“capsfilter”, NULL);
GstCaps *caps = gst_caps_from_string(“video/x-h264, stream-format=(string)byte-stream, alignment=(string)au”);
g_object_set(G_OBJECT(capsfilter_sr), “caps”, caps, NULL);
gst_caps_unref(caps);
GstElement *enc_sr = gst_element_factory_make(“nvv4l2h264enc”, NULL);
GstElement *parse_sr = gst_element_factory_make(“h264parse”, NULL);
gst_bin_add_many(GST_BIN(pipeline),
queue_sr, enc_sr, parse_sr, capsfilter_sr,
smart_record_ctx[source_id]->recordbin,
NULL);
… later linking this to nvosd’s after demux element.
“”"

then in my probe after ml Im starting a video recording per detection:
“”"
if (NvDsSRStart(smart_record_ctx[source_id], &session_id, start_time, duration, GUINT_TO_POINTER(source_id)) == NVDSSR_STATUS_OK) {…}
“”"
and my callback is:
“”"
static gpointer smart_record_callback(NvDsSRRecordingInfo *info, gpointer userData) {
g_print(" [Callback] Smart record done. Session: %u File: %s/%s\n",
info->sessionId, info->dirpath, info->filename);

guint source_id = GPOINTER_TO_UINT(userData);
g_print(" [Callback] Source ID: %u\n", source_id);
// use source id to flag recording for particular source as ended
return nullptr;
}
“”"

however Im mostly getting:
RunUserCallback:207: No video stream found
in my console logs. On random occasions callback did work though, but mostly it fails with this. However videos are saved and Im able to play them back on VLC just fine. I need callback to time allow next video to be recorded and also trigger image saving once for each video.

Thanks in advence.

about “No video stream found”, please refer to this topc.
do you mean some videos can be played with VLC, but smart_record_callback is not triggered for these videos? if so, Since DeepStream uses Gstramer to analyze the stream, could you use the following cmd to play these videos?

gst-launch-1.0 nvurisrcbin uri=file:///xxx.mp4 ! fakesink

Yes you understand it right.
The command you give:

jensen@tegra-ubuntu:~/deepstream-factorymonitor$ gst-launch-1.0 nvurisrcbin uri=file:/home/jensen/deepstream-factorymonitor/26-05-25_15-20-48-465-UTC705c29_00000_20250526-152100_748149.mp4  ! fakesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NvMMLiteBlockCreate : Block : BlockType = 261 

hangs as such. I’m not sure if its the correct behaviour.
I will try checking the topic.

Thanks for the sharing! Wondering if it is a decoder bug, could you share this test file? Thanks! You can use forum private email. please click forum avatar → "personal messages’ → “view all personal messages” → “new message”.

1 Like

send it now thanks.

sorry for the late reply! smart record does not transcode.

  1. seems the mp4 timestamp is not correct. could you try the mkv format by referring the following code? Thanks!
sr_params.containerType = NVDSSR_CONTAINER_MKV;
  1. could you share the complete pipeline? where did you put the smart record element?