SmartRecord write 0 byte video

I extracted the event video save feature from project: deepstream-testsr (I moved this project from deepstream 6 and it worked in deepstream 5 with jetpack 4.5). When running, the console screen log start saving and save done, but the recorded video has a capacity of 0 bytes and only the first video can be recorded. (10s for each video).
I need your help to save the video normally. Thank you!
This is my code.

static gboolean
smart_record_event_generator(gpointer data)
  NvDsSRSessionId sessId = 0;
  NvDsSRContext *ctx = (NvDsSRContext *)data;
  guint startTime = START_TIME;
  guint duration = SMART_REC_DURATION;

  if (ctx->recordOn)
    g_print("Recording done.\n");
    if (NvDsSRStop(ctx, 0) != NVDSSR_STATUS_OK)
      g_printerr("Unable to stop recording\n");
    g_print("Recording started..\n");
    if (NvDsSRStart(ctx, &sessId, startTime, duration,
                    NULL) != NVDSSR_STATUS_OK)
      g_printerr("Unable to start recording\n");
  return TRUE;

int main(int argc, char *argv[])
  DataContainer_t container;
  NvDsSRInitParams params = {0};

  params.containerType = NvDsSRContainerType::NVDSSR_CONTAINER_MP4;
  params.videoCacheSize = CACHE_SIZE_SEC;
  params.defaultDuration = SMART_REC_DEFAULT_DURATION;
  params.fileNamePrefix = "With_BBox";

  for (i = 0; i < num_sources; i++)
    if (NvDsSRCreate(&[i], &params) != NVDSSR_STATUS_OK)
      g_printerr("Failed to create smart record bin for stream %d\n", i);
      return -1;
    gst_bin_add_many(GST_BIN(pipeline),[i]->recordbin, NULL);

    if (!gst_element_link_many(tee_pre_decode,[i]->recordbin, NULL))
      g_printerr("Elements of recordbin %d could not be linked. Exiting.\n", i);
      return -1;

    g_timeout_add(SMART_REC_INTERVAL * 1000, smart_record_event_generator,

  tee_pre_decode = gst_element_factory_make("tee", "tee-pre-decode");
  tee_post_osd = gst_element_factory_make("tee", "tee-post-osd");

  gst_bin_add_many(GST_BIN(pipeline), queue1, tee_pre_decode, pgie, queue2, nvtracker, queue3,
                   nvdsanalytics, queue4, tiler, queue5,
                   nvvidconv, queue6, nvosd, tee_post_osd, queue7, transform, sink,

  if (!gst_element_link_many(streammux, queue1, pgie, queue2, nvtracker,
                             queue3, nvdsanalytics, queue4, tiler, queue5,
                             nvvidconv, tee_post_osd, queue6, nvosd, queue7, transform, sink, NULL))
    g_printerr("Elements could not be linked. Exiting.\n");
    return -1;

• Hardware Platform (Jetson / GPU): JetsonNano
• DeepStream Version: 5.0
• JetPack Version (valid for Jetson only): 4.5
• TensorRT Version: 7.0
• Issue Type( questions, new requirements, bugs): bugs

Sorry for the late response, our team will do the investigation and provide suggestions soon. Thanks

1 did you modify the code based on deepstream-testsr of deepstream 6.0?
2 About this code “gst_element_link_many(tee_pre_decode,[i]->recordbin”, why did you link many recordbin to tee_pre_decode? there is a parallel limitation Frequently Asked Questions — DeepStream 6.1.1 Release documentation

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.