End of stream during smart record throwing error: RunUserCallback:199

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) DGPU
• DeepStream Version 6.0
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only) 470.57.02
• Issue Type( questions, new requirements, bugs) question / bug
**• How to reproduce the issue ? **
First, I want to say that smart_record is a great feature and we’ve made very good use of it. I’d like to share that we found that it’s important to join the recordCtx->resetThread in order to reliably stop smart record and complete the process of writing the new video to disk. We need to rename the video file after it’s complete since we can’t customize the file name (would be a very helpful feature, btw) and we struggled for weeks not understanding why the smart_record_callback function we set in recordCtx wasn’t always being called. For anyone else that’s looking around for answers, this snippet might help if it’s placed right after calling NvDsSRStop (please correct me if I’m wrong):

while (!recordCtx->resetThread) {
  g_usleep(10000);
  NVGSTDS_INFO_MSG_V("recordCtx->resetThread is NULL");
}
  NVGSTDS_INFO_MSG_V("Joining recordCtx->resetThread");
  g_thread_join(recordCtx->resetThread);
while (!recordCtx->resetDone) {
  g_usleep(10000);
  g_print("*");
}

After that, you can safely call NvDsSRDestroy. The above works great for RTSP feeds, however, we’ve found that if an EOS event occurs on a video file while smart record is running, we get the RunUserCallback:199 error and the above snippet is of no help; the thread seems to have already been joined (maybe by the RunUserCallback?), but our callback function never gets called and the video file is either corrupted or incomplete. Is there a way to handle the above callback error and finish writing to file gracefully? We tried looping the video file in the hopes that new frames would let the smart_record routine finish, but the RunUserCallback error still gums things up. Any suggestions?

@Fiona.Chen Can I ask for your input on this?

Update: we found that the failure only happens with small cache sizes. For example, if smart-rec-video-cache=2 and smart-rec-start-time=2. The error occurs if the EOS event happens shortly after starting smart record with these values. Must be that it hasn’t had time to fill the buffer, which is understandable. However, we still need a way to handle this error.