Hi,
I am converting a pipeline from a gst_parse_launch to a programmatic implementation.
The following gst-launch-1.0 call works fine:
gst-launch-1.0 nvarguscamerasrc name=CAMsource sensor-id=0 sensor-mode=0 tnr-mode=0 aelock=0 exposuretimerange=“50000 1000000” gainrange=“1 16” ! ‘video/x-raw(memory:NVMM),width=3840,height=2160,framerate=36/1,format=NV12’ ! nvvidconv name=NV12toYUVconv ! ‘video/x-raw(memory:NVMM),format=I420’ ! nvvidconv name=YUVtoRGBAconv ! nvvidconv ! nveglglessink -e
However when I try to build the pipe via function calls and setting object params, the ‘video/x-raw(memory:NVMM),format=I420’ capsfilter seems to seg fault. If I add width, height, and framerate properties, it works fine. Why would this fail?
// create pipeline class to hold all the elements
GstElement *pipeline, *cam_source, *cam_source_caps_filter, *cam_conv_nv12_yuv,
*yuv_conv_caps_filter, *cam_conv_yuv_rgba, *rgba_conv_caps_filter, *cam_conv_rgba_sink,
*video_stream_sink;
GstBus * bus;
GstMessage * msg;
GstStateChangeReturn ret;
gst_init(&argc, &argv);
cam_source = gst_element_factory_make("nvarguscamerasrc", "cam_source");
cam_source_caps_filter = gst_element_factory_make("capsfilter", "cam_source_caps_filter");
cam_conv_nv12_yuv = gst_element_factory_make("nvvidconv", "cam_conv_nv12_yuv");
yuv_conv_caps_filter = gst_element_factory_make("capsfilter", "yuv_conv_caps_filter");
cam_conv_yuv_rgba = gst_element_factory_make("nvvidconv", "cam_conv_yuv_rgba");
rgba_conv_caps_filter = gst_element_factory_make("capsfilter", "rgba_conv_caps_filter");
cam_conv_rgba_sink = gst_element_factory_make("nvvidconv", "cam_conv_rgba_sink");
video_stream_sink = gst_element_factory_make("nveglglessink", "video_stream_sink");
/* Create the empty pipeline */
pipeline = gst_pipeline_new("cam-pipeline");
if (!pipeline || !cam_source || !cam_source_caps_filter || !cam_conv_nv12_yuv ||
!yuv_conv_caps_filter || !cam_conv_yuv_rgba || !rgba_conv_caps_filter ||
!cam_conv_rgba_sink || !video_stream_sink) {
g_printerr("Not all elements could be created.\n");
return -1;
}
/* Build the pipeline */
gst_bin_add_many(GST_BIN(pipeline),
cam_source,
cam_source_caps_filter,
cam_conv_nv12_yuv,
yuv_conv_caps_filter,
cam_conv_yuv_rgba,
rgba_conv_caps_filter,
cam_conv_rgba_sink,
video_stream_sink,
NULL);
if (gst_element_link_many(cam_source,
cam_source_caps_filter,
cam_conv_nv12_yuv,
yuv_conv_caps_filter,
cam_conv_yuv_rgba,
rgba_conv_caps_filter,
cam_conv_rgba_sink,
video_stream_sink,
NULL) != TRUE) {
g_printerr("Elements could not be linked.\n");
gst_object_unref(pipeline);
return -1;
}
std::cout << "Built the pipe" << std::endl;
g_object_set(cam_source,
"name",
"cam-source",
"sensor-id",
0,
"sensor-mode",
0,
"tnr-mode",
0,
"aelock",
0,
"exposuretimerange",
"50000 1000000",
"gainrange",
"1 16",
NULL);
std::cout << "Set cam element 1 props" << std::endl;
g_object_set(cam_source_caps_filter,
"caps",
"video/x-raw(memory:NVMM),width=" + std::to_string(w) +
",height=" + std::to_string(h) + ",framerate=36/1,format=NV12",
NULL);
std::cout << "Set capsfilter 1 element 2 props" << std::endl;
g_object_set(
yuv_conv_caps_filter, "caps", "video/x-raw(memory:NVMM),format=(string)I420", NULL);
std::cout << "Set element 4 props" << std::endl;
g_object_set(rgba_conv_caps_filter,
"caps",
"video/x-raw(memory:NVMM),width=" + std::to_string(w / scale_factor) +
",height=" + std::to_string(h / scale_factor) + ",format=RGBA",
NULL);
std::cout << "Set element 6 props" << std::endl;
This code seg faults after the “Set capsfilter 1 element 2 props” print statement.