# How to access the filename of Smart Record

• Hardware Platform (Jetson / GPU) dGPU
• DeepStream Version 5.1
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only) 460.73
• 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)

There are 30 streams running in one analytics group each detecting a scenario and creating an image and a smart record at each detected event. I need to populate the name of the image (which is running fine) and the name of the smart-record (not working as instead of getting/ setting the filename in NvDsStart I was constructing the same using fileprefix + CameraID + PID + Date .mp4 or mkv). Around 70% of the time I am able to predict the smart record file name but 30% of the time it misses. Since I need to write the Smart Record filename in the event I cannot wait for Smart Record to finish.
Is there an alternate way I can get the filename the moment I invoke the NvDsSRStart?
https://forums.developer.nvidia.com/t/how-to-get-the-smart-record-file-name-in-the-call-back-function/179866/7

/**
* \brief  Starts the video recording.
*
* This function starts writing the cached video data to a file. It returns
* the session id which later can be used in NvDsSRStop() to stop the
* corresponding recording.
*
* Here startTime specifies the seconds before the current time and duration
* specifies the seconds after the start of recording.
* If current time is t1, content from t1 - startTime to t1 + duration will
* be saved to file. Therefore a total of startTime + duration seconds of data
* will be recorded.
*
* @param[in] ctx         A pointer to a \ref NvDsSRContext.
* @param[out] sessionId  A pointer to a \ref NvDsSRSessionId.
* @param[in] startTime   Seconds before the current time. Should be less than video cache size.
* @param[in] duration    Duration value in seconds after the start of recording.
* @param[in] userData    A pointer to user specified data.
*
* @return NVDSSR_STATUS_OK if successful, or corresponding error otherwise.
*/
NvDsSRStatus NvDsSRStart (NvDsSRContext *ctx, NvDsSRSessionId *sessionId,
guint startTime, guint duration, gpointer userData);


When you use NvDsSRStart(), the filesink element is recorded in NvDsSRContext, you can get file name through filesink element.

How to access the filesink element recorded in NvDsSRContext. Can I get the filename in filesink element while the smart recording is ON?

How much do you know about gstreamer and gobject?

NvDsSRContext is defined in /opt/nvidia/deepstream/deepstream/sources/includes/gst-nvdssr.h

typedef struct NvDsSRContext
{
/** parent bin element. */
GstElement *recordbin;
/** queue element to cache the content. */
GstElement *recordQue;
/** child bin to save the content to file. */
GstElement *encodebin;
/** filesink element */
GstElement *filesink;
/** flag to check the key frame. */
gboolean gotKeyFrame;
/** flag to check if recording is on */
gboolean recordOn;
/** flag to check if encodebin is reset */
gboolean resetDone;
/** flag to check if encodebin is in playing state. */
gboolean isPlaying;
/** initialization parameters */
NvDsSRInitParams initParams;
/** mutex to control the flow */
GMutex flowLock;
/** thread to reset the encodebin */
/** pointer to user provided data */
gpointer uData;
/** pointer to private data */
gpointer privData;
} NvDsSRContext;


https://gstreamer.freedesktop.org/documentation/coreelements/filesink.html?gi-language=c
https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#g-object-get-property
You can use g_object_get_property () to get the ‘location’ property value.

This is basic Gobject and gstreamer coding skills. It has nothing to do with deepstream. Please find useful resources in internet.

Please make sure you are familiar with Gstreamer knowledge and coding skills before you start with deepstream.

Thanks. I will give it a try.

One last question: Can I get the filename in filesink element while the smart recording is ON?

What do you mean?

Please check filesink property information in filesink. If there is any limitation, it will elaborate in the page.

I tried this
NvDsSRStart(ctx, &sessId, startTime, duration, NULL);
gchar *video_file_name_direct;
GValue val = G_VALUE_INIT;
g_object_get_property(G_OBJECT (ctx->filesink), “location”, &val);
video_file_name_direct = gst_value_serialize (&val);
g_print ("\n Smart Record : %s ", video_file_name_direct);
g_free (video_file_name_direct);
g_value_unset (&val);

But I get NULL output in filename.

Smart Record : (null)

Can you please check what am I doing wrong here