Regarding doubt about smart record trigger start/stop deepsream-testsr

if you want only one recording with 60s, please remove timer smart_record_event_generator, and call NvDsSRStart and NvDsSRStop once.

static gboolean
smart_record_event_generator (gpointer data)
{
NvDsSRSessionId sessId = 0;
NvDsSRContext *ctx = (NvDsSRContext *) data;
guint startTime = 0;
guint duration = 15;
static gboolean recordState = FALSE;

if (ctx->recordOn) {
g_print(“smart record done!”);
g_print (“Recording done.\n”);
if (NvDsSRStop (ctx, 0) != NVDSSR_STATUS_OK)
g_printerr (“Unable to stop recording\n”);
} else {
g_print (“Recording started…\n”);
if (NvDsSRStart (ctx, &sessId, startTime, duration,
NULL) != NVDSSR_STATUS_OK)
g_printerr (“Unable to start recording\n”);
recordState = TRUE;
}

return TRUE;
}

this is a code of smart record event NvDsSRStart and NvDsSRStop once. what i need to change

did the logs “Recording started” and “Recording done” all print?

ok i will try and update to you

static gboolean
smart_record_event_generator (gpointer data)
{
NvDsSRSessionId sessId = 0;
NvDsSRContext *ctx = (NvDsSRContext *) data;
guint startTime = 0;
guint duration = 15;
static gboolean recordState = FALSE;

if (ctx->recordOn) {
g_print(“smart record done!”);
g_print (“Recording done.\n”);
NvDsSRStop (ctx, 0);
g_printerr (“Unable to stop recording\n”);
} else {
g_print (“Recording started…\n”);
NvDsSRStart (ctx, &sessId, startTime, duration,
NULL);
g_printerr (“Unable to start recording\n”);
recordState = TRUE;
}

return TRUE;
}

what else should id do for if total duration is complete then it should stop

even i was tried in probe that error is showed such as first need to use this function

static gboolean smart_record_event_generator(gpointer data) {
NvDsSRContext *ctx = (NvDsSRContext *) data;
guint startTime = 0;
guint duration = 60; // Total duration of recording (60 seconds)
guint segmentDuration = 10; // Duration of each segment (10 seconds)
guint numSegments = duration / segmentDuration; // Number of segments

if (ctx->recordOn) {
g_print(“Recording done.\n”);
if (NvDsSRStop(ctx, 0) != NVDSSR_STATUS_OK)
g_printerr(“Unable to stop recording\n”);
} else {
g_print(“Recording started…\n”);

// Start recording for each segment
for (guint i = 0; i < numSegments; i++) {
  guint segmentStartTime = startTime + (i * segmentDuration);
  NvDsSRSessionId sessId = 0;

  if (NvDsSRStart(ctx, &sessId, segmentStartTime, segmentDuration, NULL) != NVDSSR_STATUS_OK) {
    g_printerr("Unable to start recording\n");
    break;
  }
}

}

return G_SOURCE_CONTINUE;
}

what else should i modify this code for storing video 10 seconds segements and total duraiton is 60

if you want to start a new recording by NvDsSRStart, please call NvDsSRStop to stop the running recording first.

should i call in smart_record_event_generator function right

Sorry for the late reply, you can call smart_record_event_generator to start a new recording, or directly call NvDsSRStart to start a new recording.

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