Few questions regarding Smart Recording

Dear Experts,

I have the following inquiries regarding smart recording feature of Deepstream SDK. I am using version 5.0.

  1. Can I start and stop recording on manual trigger instead of duration for stop? In other words can I keep duration open so that I can stop recording by calling NvDsSRStop() whenever I want?

  2. What does duration actually do? according to the manual it stops recording after the duration seconds but why then we still need to call NvDsSRStop() according to test5 example. Shouldn’t the function NvDsSRStop() be called automatically internally after duration seconds?

  3. Is there any variable either in NvDsSRContext or anywhere that indicates the duration is over? I suppose “recordOn” in NvDsSRContext only indicates that a recording is started regardless duration expired or not.

  4. Can I call NvDsSRStart() while another previous recording is in progress? or I have to close previous one first to start new recording?


I’ve used smart record quite a bit so will answer the best I can:

  1. Yes you can start and stop recording however you wish and at any time. Simply call NvDsSRStart(...) to start recording and then call NvDsSRStop(...) to stop - or alternatively have it automatically stopped by setting the duration in the NvDsSRStart(...) call.
    The only thing to note is that you can not start multiple recordings at the same time for the same source.

  2. Duration sets the duration for the recording session. i.e. if I have duration set to 30 seconds it will record a 30 seconds long video clip (plus or minus a bit due to GOP). It will automatically stop after the duration or at any time you can stop it instantly with NvDsSRStop(...).

  3. As you suggested - ctx->recordOn can be used to see if a recording is currently taking place.

  4. Correct. Only one recording is possible on one stream at a time. You will get an error from NvDsSRStart(...) if you try.

Thanks @jasonpgf2a for your reply. most of your answers match with my findings/assumptions. However, if I can start and stop recording anytime, what would the duration I need to specify in this case? would this be a very big number? so that no matter when I decide to stop, it would never exceed the duration?

Leave it at 0 or set it as a high number as a fail safe.

Thanks, fail safe idea worked.

Hi, @jasonpgf2a , I have couple of more questions. Maybe you can answer:

  1. Is there a way to perform smart recording in a way so that it produces chunks of video files. for example, if you set max chunk size of 30 sec and smart recording is performed for 1 minute 20 seconds, it will automatically produce the video files in 3 chunks: 30 sec, 30 sec and 20 sec?

  2. This question is regarding the gstreamer filesrc. For filesrc, is there a way to specify an array of files so that it plays the files one after another automatically?

Hi @jasonpgf2a, did you need to pass different session ids for each source? because recording might be started while the same session is actively recording for another source…

What is the correct way to do this? because when I try deepstream-app with smart-recording configured for 1 source, the behaviour is perfect. However, when configuring smart-record for multiple sources the duration of the videos are no longer consistent (different duration for each video).
How to extend this to work with multiple sources while keeping the duration of the videos consistent?

Hi @a7med.hish I seem to be able to have multiple smart records running on different cameras at the same time.

When I instantiate the smart record bin I save the context (ctx) into an array which maps the camera id to the context. Then whenever I get a specific detection I am interested in, I call this - passing in the correct ctx for the camera id:

rc = NvDsSRStart (ctx, &sessId, startTime, duration, GUINT_TO_POINTER (source_id));

Source id is the camera id above.

This allows multiple smart records to be occurring in parallel.

@jasonpgf2a, thanks a lot for your reply.

I am building on top of deepstream-test5 app and I think they are doing exactly as you described by attaching a new NvDsSRContext to each source in their function create_rtsp_src_bin. However, when I try to run the app with smart-record defined for multiple sources the duration is no longer the same for all videos.

Do you have any idea why?
Did you implement a custom app with the method you described and it didn’t cause any change in the duration of videos? or did you also use deepstream-app or test5?