I extracted the event video save feature from project: deepstream-testsr (I moved this project from deepstream 6 and it worked in deepstream 5 with jetpack 4.5). When running, the console screen log start saving and save done, but the recorded video has a capacity of 0 bytes and only the first video can be recorded. (10s for each video).
I need your help to save the video normally. Thank you!
This is my code.
static gboolean
smart_record_event_generator(gpointer data)
{
NvDsSRSessionId sessId = 0;
NvDsSRContext *ctx = (NvDsSRContext *)data;
guint startTime = START_TIME;
guint duration = SMART_REC_DURATION;
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");
if (NvDsSRStart(ctx, &sessId, startTime, duration,
NULL) != NVDSSR_STATUS_OK)
g_printerr("Unable to start recording\n");
}
return TRUE;
}
int main(int argc, char *argv[])
{
DataContainer_t container;
NvDsSRInitParams params = {0};
params.containerType = NvDsSRContainerType::NVDSSR_CONTAINER_MP4;
params.videoCacheSize = CACHE_SIZE_SEC;
params.defaultDuration = SMART_REC_DEFAULT_DURATION;
params.fileNamePrefix = "With_BBox";
for (i = 0; i < num_sources; i++)
{
if (NvDsSRCreate(&container.data[i], ¶ms) != NVDSSR_STATUS_OK)
{
g_printerr("Failed to create smart record bin for stream %d\n", i);
return -1;
}
gst_bin_add_many(GST_BIN(pipeline), container.data[i]->recordbin, NULL);
if (!gst_element_link_many(tee_pre_decode, container.data[i]->recordbin, NULL))
{
g_printerr("Elements of recordbin %d could not be linked. Exiting.\n", i);
return -1;
}
g_timeout_add(SMART_REC_INTERVAL * 1000, smart_record_event_generator,
container.data[i]);
}
tee_pre_decode = gst_element_factory_make("tee", "tee-pre-decode");
tee_post_osd = gst_element_factory_make("tee", "tee-post-osd");
gst_bin_add_many(GST_BIN(pipeline), queue1, tee_pre_decode, pgie, queue2, nvtracker, queue3,
nvdsanalytics, queue4, tiler, queue5,
nvvidconv, queue6, nvosd, tee_post_osd, queue7, transform, sink,
NULL);
if (!gst_element_link_many(streammux, queue1, pgie, queue2, nvtracker,
queue3, nvdsanalytics, queue4, tiler, queue5,
nvvidconv, tee_post_osd, queue6, nvosd, queue7, transform, sink, NULL))
{
g_printerr("Elements could not be linked. Exiting.\n");
return -1;
}
}
• Hardware Platform (Jetson / GPU): JetsonNano
• DeepStream Version: 5.0
• JetPack Version (valid for Jetson only): 4.5
• TensorRT Version: 7.0
• Issue Type( questions, new requirements, bugs): bugs