# Few questions regarding Smart Recording

**URL:** <https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410>\
**Category:** DeepStream SDK\
**Created:** [February 14, 2021, 10:21pm UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410 "2021-02-14T22:21:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![caruofc](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@caruofc](https://forums.developer.nvidia.com/u/caruofc)\
**Post date:** [February 14, 2021, 10:21pm UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/1 "2021-02-14T22:21:09Z")

</div>

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?

Thanks.

---

<div class="post-metadata">

**Author:** ![jasonpgf2a](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jasonpgf2a/32/15416_2.png) [@jasonpgf2a](https://forums.developer.nvidia.com/u/jasonpgf2a)\
**Post date:** [February 15, 2021, 6:10am UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/2 "2021-02-15T06:10:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![caruofc](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@caruofc](https://forums.developer.nvidia.com/u/caruofc)\
**Post date:** [February 15, 2021, 6:55am UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/3 "2021-02-15T06:55:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jasonpgf2a](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jasonpgf2a/32/15416_2.png) [@jasonpgf2a](https://forums.developer.nvidia.com/u/jasonpgf2a)\
**Post date:** [February 15, 2021, 12:17pm UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/4 "2021-02-15T12:17:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![caruofc](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@caruofc](https://forums.developer.nvidia.com/u/caruofc)\
**Post date:** [February 15, 2021, 7:14pm UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/5 "2021-02-15T19:14:07Z")

</div>

Thanks, fail safe idea worked.

---

<div class="post-metadata">

**Author:** ![caruofc](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@caruofc](https://forums.developer.nvidia.com/u/caruofc)\
**Post date:** [June 13, 2021, 8:02pm UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/6 "2021-06-13T20:02:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![a7med.hish](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@a7med.hish](https://forums.developer.nvidia.com/u/a7med.hish)\
**Post date:** [October 4, 2021, 12:23pm UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/7 "2021-10-04T12:23:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jasonpgf2a](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jasonpgf2a/32/15416_2.png) [@jasonpgf2a](https://forums.developer.nvidia.com/u/jasonpgf2a)\
**Post date:** [October 6, 2021, 5:45am UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/8 "2021-10-06T05:45:50Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![a7med.hish](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@a7med.hish](https://forums.developer.nvidia.com/u/a7med.hish)\
**Post date:** [October 6, 2021, 1:40pm UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/9 "2021-10-06T13:40:51Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![yingliu](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/yingliu/32/136703_2.png) [@yingliu](https://forums.developer.nvidia.com/u/yingliu)\
**Post date:** [September 7, 2023, 8:01am UTC](https://forums.developer.nvidia.com/t/few-questions-regarding-smart-recording/168410/10 "2023-09-07T08:01:06Z")

</div>


