A segfault occurs when creating NvVideoDecoder inside a child process

Hi,
Please try the steps:

  1. Apply the patch to 00_video_decode:
diff --git a/multimedia_api/ll_samples/samples/00_video_decode/video_decode_main.cpp b/multimedia_api/ll_samples/samples/00_video_decode/video_decode_main.cpp
index 8bb14a9..fcda7dd 100644
--- a/multimedia_api/ll_samples/samples/00_video_decode/video_decode_main.cpp
+++ b/multimedia_api/ll_samples/samples/00_video_decode/video_decode_main.cpp
@@ -39,6 +39,7 @@
 #include <fcntl.h>
 #include <poll.h>
 #include <nvbuf_utils.h>
+#include <sys/stat.h>
 
 #include "video_decode.h"
 #include "nvbuf_utils.h"
@@ -992,6 +993,8 @@ dec_capture_loop_fcn(void *arg)
     NvVideoDecoder *dec = ctx->dec;
     struct v4l2_event ev;
     int ret;
+    NvBufferSession session;
+    session = NvBufferSessionCreate();
 
     cout << "Starting decoder capture loop thread" << endl;
     /* Need to wait for the first Resolution change event, so that
@@ -1152,6 +1155,7 @@ dec_capture_loop_fcn(void *arg)
                 transform_params.transform_filter = NvBufferTransform_Filter_Nearest;
                 transform_params.src_rect = src_rect;
                 transform_params.dst_rect = dest_rect;
+		transform_params.session = session;
 
                 if(ctx->capture_plane_mem_type == V4L2_MEMORY_DMABUF)
                     dec_buffer->planes[0].fd = ctx->dmabuff_fd[v4l2_buf.index];
@@ -1162,7 +1166,6 @@ dec_capture_loop_fcn(void *arg)
                     cerr << "Transform failed" << endl;
                     break;
                 }
-
                 /* Write raw video frame to file. */
                 if (!ctx->stats && ctx->out_file)
                 {
@@ -1220,6 +1223,7 @@ dec_capture_loop_fcn(void *arg)
         }
     }
 #endif
+    NvBufferSessionDestroy(session);
     cout << "Exiting decoder capture loop thread" << endl;
     return NULL;
 }
@@ -1802,6 +1806,7 @@ decode_proc(context_t& ctx, int argc, char *argv[])
     ctx.in_file = (std::ifstream **)malloc(sizeof(std::ifstream *)*ctx.file_count);
     for (uint32_t i = 0 ; i < ctx.file_count ; i++)
     {
+	cout << "---> opening " << ctx.in_file_path[i] << endl;
         ctx.in_file[i] = new ifstream(ctx.in_file_path[i]);
         TEST_ERROR(!ctx.in_file[i]->is_open(), "Error opening input file", cleanup);
     }
@@ -2212,7 +2217,7 @@ cleanup:
   * @param argv : Argument Vector
   */
 int
-main(int argc, char *argv[])
+main_1(int argc, char *argv[])
 {
     /* create decoder context. */
     context_t ctx;
@@ -2239,3 +2244,29 @@ main(int argc, char *argv[])
 
     return ret;
 }
+
+static int daemonize(void)
+{
+pid_t pid;
+int rc;
+
+// daemon initialzation
+if ( (pid = fork()) < 0 )
+	return -1;
+else if (pid != 0)
+	exit(0);		// parent goes bye-bye
+	
+// child continues
+setsid();			// become session leader
+rc = chdir("/");			// change working directory
+umask(0);			// clear our file mode creation mask
+return rc;
+}
+
+int
+main(int argc, char *argv[])
+{
+	daemonize();
+	main_1(argc,argv);
+	return 0;
+}
  1. Rebuild the app and run:
$ ./video_decode H264 -o /home/nvidia/a.yuv --disable-rendering /usr/src/jetson_multimedia_api/data/Video/sample_outdoor_car_1080p_10fps.h264
1 Like