How to run the smart recorder in uri (file) instead of rtsp?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version 6.0

I’m using the smart recorder well. But it only runs when the type is rtsp, so I’m going to change it.
I set the source0 type to 3(multi-uri) in config txt and changed the create_uridecode_src_bin() part in deepstream_source_bin.c.

The changed parts are as follows.

static gboolean
create_uridecode_src_bin (NvDsSourceConfig * config, NvDsSrcBin * bin)
{
  ...

  NvDsSRContext *ctx = NULL;

  ...

if (config->smart_record) {
    NvDsSRInitParams params = {0};
    params.containerType = (NvDsSRContainerType) config->smart_rec_container;
    if (config->file_prefix)
      params.fileNamePrefix = g_strdup_printf ("%s_%d", config->file_prefix, config->camera_id);
    params.dirpath = config->dir_path;
    params.cacheSize = config->smart_rec_cache_size;
    params.defaultDuration = config->smart_rec_def_duration;
    params.callback = smart_record_callback;
    if (NvDsSRCreate (&ctx, &params) != NVDSSR_STATUS_OK) {
      NVGSTDS_ERR_MSG_V ("Failed to create smart record bin");
      g_free (params.fileNamePrefix);
      goto done;
    }
    g_free (params.fileNamePrefix);
    gst_bin_add (GST_BIN(bin->bin), ctx->recordbin);
    bin->recordCtx = (gpointer) ctx;
  }
NVGSTDS_LINK_ELEMENT (bin->fakesink_queue, bin->fakesink);
  if (config->dewarper_config.enable) {
    gst_bin_add_many (GST_BIN (bin->bin), bin->dewarper_bin.bin, NULL);
    NVGSTDS_LINK_ELEMENT (bin->tee, bin->dewarper_bin.bin);
    NVGSTDS_LINK_ELEMENT (bin->dewarper_bin.bin, bin->cap_filter);
  } else {
    link_element_to_tee_src_pad (bin->tee, bin->cap_filter);
  }
  NVGSTDS_LINK_ELEMENT (bin->cap_filter, bin->nvvidconv);
  NVGSTDS_LINK_ELEMENT (bin->nvvidconv, bin->cap_filter1);
  link_element_to_tee_src_pad (bin->tee, bin->fakesink_queue);
  
  if (ctx){
     g_print("\n\nin ctx!!\n\n");
     link_element_to_tee_src_pad(bin->tee, ctx->recordbin);
  }
  g_object_set (G_OBJECT (bin->fakesink), "sync", FALSE, "async", FALSE, NULL);
  g_object_set (G_OBJECT (bin->fakesink), "enable-last-sample", FALSE, NULL);
  ret = TRUE;
  GST_CAT_DEBUG (NVDS_APP,
      "Decode bin created. Waiting for a new pad from decodebin to link");
done:
    ...

For your information, the smart record activation part was taken from the create_rtsp_src_bin part.

I think there will be no problem attaching ctx->recordbin to the bin->tee , but the error appears as follows.

** ERROR: <cb_newpad:235>: Failed to link decodebin to pipeline
** INFO: <bus_callback:180>: Pipeline running
ERROR from qtdemux0: Internal data stream error.
Debug info: qtdemux.c(6073): gst_qtdemux_loop (): /GstPipeline:pipeline/GstBin:multi_src_bin/GstBin:src_sub_bin0/GstURIDecodeBin:src_elem/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-linked (-1)

How to run the smart recorder in uri (file) instead of rtsp?

The smart record bin only support record encoded(compressed) video data. So you need to add video encoder before the smart record bin.

The smart record API introduction, please refer to Smart Video Record — DeepStream 6.1.1 Release documentation

Thank you for your reply!.
How can I add a video encoder before the smart record bin?

Isn’t changing the video encoder changing the sink_bin.c part?
If correct, should I understand that the smart record bin generates it first and then adds a video encoder in the output part (sink)?

And isn’t the video data the video file (mp4) that goes into the mulit URI in type 3?
I think encoding an image with rtsp and encoding an image with a file are the same. How is it different?

How much do you know about gstreamer knowledge and coding skills?
Please make sure you are familiar with gstreamer coding skills before you start with DeepStream. GStreamer: open source multimedia framework

What do you want to record? If you just want to record the source, you don’t need to touch the code of sink.

uridecodebin will parse and decode the mp4 file into raw video data(such as RGB,YUV,…). uridecodebin (gstreamer.freedesktop.org) So you need to add an video encoder to encode the video to compressed video(H264, H265,…)

Please google these basic image and video knowledge.

Please learn basic video knowledge and gstreamer coding skills before you start with deepstream.

thank you!
I was a lack of basic knowledge of gstream.
I should study basic things

thanks!!

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