In Smart Record is the video cache buffer of previous frames still maintained while we are writing data to file?

I am recording video (having pre-post buffer) on certain events for which i am using smart record plugin. The pre-post buffer for now is fixed to 10 seconds, and the maximum size of video (max chunk_size) is one minute.

so i have applied a logic where if a new event comes before we have stopped the current recording and the post buffer for this new event is satisfied in the chunk size we keep on recording else this event will be recorded in a new file.

first event E1 came at time t1, on it i started recording R1. for first event the recording stop time is t1+10 and actual recording start time is t1-10.
Now a new event E2 came at t2 and the recording (R1) is still on so i check if (t2+10) - (t1-10) is less than max chunk_size, if it is then the time when recording is to be stopped is set to t2+10 else this event will be recorded in separate video file which will be started once the current video recording (R1) stops.

Now when i start recording R2 for event E2 because it didn’t satify the max chunk_size condition it’s recording dosen’t contain pre buffer, it starts from where the previous recording file R1 ended, even though i have specified pre buffer duration as 10 second.

i know that data will be duplicated in what i am trying to achieve but that i not a problem for me.
Is the video cache emptied once we record a file or is the video cache still maintained ?? if yes then is there a option to not empty it.

1 Like

@pawany16 The video cache is always maintained - yes. Think of it just like a normal gstreamer queue element with a fixed queue-size of x-seconds as configured into smartrecord for the buffer size value.

@jasonpgf2a but that doesn’t seem to be the case, if i start a recording say R1 having pre-post buffer of 10 seconds and start another recording R2 (pre-post buffer 10 seconds) as soon as i stop R1, the first recording R1 contains both pre-post video data but the second recording R2 does not contain the pre buffer it starts from where the previous recording ended.
I have tested this scenario on both Deepstream version 5.0 and 5.0.1

Best to let nvidia respond then. I have an application that works on multiple cameras with events starting and stopping the recordings all the time and they all seem to have my pre-record working well so that I can see what happened x-seconds before the event occured.
There are a few parameters at play with smartrecord such as videoCacheSize, defaultDuration and startTime. Ensure that your cache size is larger than the startTime.

I have set videoCacheSize to 30 seconds, defaultDuration to 10 seconds and startTimeis always 10 seconds but i am still having the issue. Also tried changing these values but doesn’t work.

Anyways thanks for taking time out to respond.

videoCacheSize is the minimum cache size of start cache read, startTime is the maximum cache size of recording, so please set videoCacheSize < startTime

defaultDuration is the timeout of recording, the value will be overrided by the parameter of startTime when you use NvDsSRStart.
*NvDsSRStatus NvDsSRStart (NvDsSRContext ctx, NvDsSRSessionId sessionId,guint startTime, guint duration, gpointer userData)

If you want 10s previous video be cached, you’d better set videoCacheSize to 10s.

@Fiona.Chen you have completely confused me.

From what i can understand from the documentation for smart record is that

  • videoCacheSize is amount of video(in seconds) to store in memory

Size of video cache in seconds. This parameter will increase the overall memory usages of the application

  • defaultDuration is the amount to time (in seconds) after which recording will be stopped, it will be overriden by duration parameter of NvDsSRStart

in case a Stop event is not generated. This parameter will ensure the recording is stopped after a predefined default duration.

  • startTime is the amount of video (in seconds) to record before current time

smart-rec-start-time=<val in seconds>
Here, start time of recording is the number of seconds earlier to the current time to start the recording.
E.g. if t0 is the current time and N is the start time in seconds that means recording will start from t0 – N. For it to work, the video cache size must be greater than the N.

also in NvDsSRStart documentation in gst-nvdssr.h it is mentioned that

  • @param[in] startTime Seconds before the current time. Should be less than video cache size.

but you said

so please set videoCacheSize < startTime

Can you please clarify a bit more as to what you meant in your previous reply ?

When the NvDsSRStart() is called, the startTime will be set as the maximum cache buffer size. The key is NvDsSRStart(). videoCacheSize is just used by NvDSCreate(), it is the initialization value.

Yes, defaultDuration will be override by duration parameter of NvDsStart

@Fiona.Chen ok so here is what i did, i set the value of videoCacheSize to 10 sec and startTime to 30 sec but i am still unable to achieve what i meant to

my second recording still doesn’t contain pre-buffer video, it starts from where the previous ended.

is this possible with smart record, and what would be the parameters that you would suggest to achieve this ?

The smart recording can not record overlapped videos by one smart recording bin. The cached video is actually a queue, it is used to do the recording in another thread but not for storing the video which has been recorded.