After we upgrade AGX JetPack version from 4.4.1 to 4.5.1 , during our Gstreamer development we face crash in libv4l2_nvargus.so when we restart camera with V4l2src. While JetPack 4.4.1 dose not have such issue.
-
How to Reproduce :
We write a simple demo C code which can 100% reproduce such crash. It 1st create Gstreamer pipeline use camera with v4l2src, then after 5 seconds release the pipeline. Then setup pipeline to use camera with v4l2src then display it with xvimagesink. After set the pipeline to play state the crash comes.Back Trace :
Thread 1 “test_camera_reo” received signal SIGSEGV, Segmentation fault.
0x0000007fb4d21090 in ?? () from /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
(gdb) bt
#0 0x0000007fb4d21090 in () at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#1 0x0000007fb4d21f9c in () at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#2 0x0000007fb4d208f8 in () at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#3 0x0000007fb4d206b8 in () at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#4 0x0000007fb7787b20 in () at /usr/lib/aarch64-linux-gnu/libv4l2.so.0
#5 0x0000007fb77836c0 in v4l2_fd_open () at /usr/lib/aarch64-linux-gnu/libv4l2.so.0
#6 0x0000007fb79e463c in () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so
#7 0x00000055557c25b0 in ()
Demo code to reproduce the crash :
#include <gst/gst.h>
int
main (int argc, char *argv)
{
GstElement *pipeline;
GstMessage *msg;
GstBus *bus;
/* Initialize GStreamer */
gst_init (&argc, &argv);
/* Build the pipeline /
/
pipeline =
gst_parse_launch
(“v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! xvimagesink”,
NULL);
*/
pipeline =
gst_parse_launch
(“v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! autovideoconvert ! nvv4l2h264enc ! h264parse ! flvmux ! queue ! rtmpsink location=rtmp://10.13.1.70/live/myStream”,
NULL);
/*
pipeline =
gst_parse_launch
(“v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! autovideoconvert ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=videotestsrc.mp4 -e”,
NULL);
/
/
pipeline =
gst_parse_launch
(“-v v4l2src device=/dev/video0 ! autovideoconvert ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=videotestsrc.mp4”,
NULL);
/
if(pipeline == NULL) {
g_print(“pipeline create failed \n”);
return 0;
}
/ Start playing */
GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print(“pipeline playing status %d \n”, ret);
// g_main_loop_run(g_main_loop_new(NULL, FALSE));
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg =
gst_bus_timed_pop_filtered (bus, 5000 * GST_MSECOND,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
/* Free resources */
if (msg != NULL) {
g_print(“Message type : %d \n”, GST_MESSAGE_TYPE(msg));
gst_message_unref (msg);
}
g_print(“wait time reached, freee pipeline now \n”);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
////////////////////////////////////////////////////////////////////
// g_usleep(2000000);
g_print(“restart camera play now \n”);
/* Build the pipeline */
pipeline =
gst_parse_launch
(“v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! xvimagesink”,
NULL);
g_print(“call gst_parse_launch ximagesink finished \n”);
/* Build the pipeline /
/
pipeline =
gst_parse_launch
(“v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvv4l2h264enc ! h264parse ! flvmux ! queue ! rtmpsink location=rtmp://10.13.1.70/live/myStream”,
NULL);
/
/ Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print(“call GST_STATE_PLAYING ximagesink finished \n”);
gst_bus_poll (GST_ELEMENT_BUS (pipeline), GST_MESSAGE_ERROR,
5000 * GST_MSECOND);
g_print(“wait time reached, freee pipeline now \n”);
/* Free resources */
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
Build command : gcc test_camera_reopen.c -o test_camera_reopen pkg-config --cflags --libs gstreamer-1.0
-
Some Narrow Down testing Info :
If the 1st time pipeline which use camera like below , do not use nvv4l2h264enc. The crash will not happen
pipeline =
gst_parse_launch
(“v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! xvimagesink”,
NULL);If the 1st time pipeline use camera and use nvv4l2h264enc to encode the video stream either rtmp push it or save it to a file. Then 2nd time setup pipeline with camera via v4l2src the crash comes.