I have the following code to create an encoding pipeline on Jetson AGX
but when I switched the encoder from omxh265enc to nvv4l2h265enc
I failed to create the pipeline (gst_element_link_many)
I googled on how to generate meaningful gstreamer debug messages, without success. But shouldn’t omxh265enc and nvv4l2h265enc be interchangeable?
Is this a bug?
gst_init(NULL, NULL); //Initialize Gstreamer
//Create pipeline, and pipeline elements
gstApp.pipeline = (GstPipeline*)gst_pipeline_new("mypipeline");
gstApp.src = (GstAppSrc*)gst_element_factory_make("appsrc", "mysrc");
gstApp.filter1 = gst_element_factory_make ("capsfilter", "myfilter1");
gstApp.encoder = gst_element_factory_make ("omxh265enc", "myomx"); // nvv4l2h264enc omxh264enc nvh265enc vaapih265enc
#endif
gstApp.filter2 = gst_element_factory_make ("capsfilter", "myfilter2");
gstApp.parser = gst_element_factory_make("h265parse" , "myparser");
gstApp.mp4mux = gst_element_factory_make("mp4mux" , "mymux");
gstApp.sink = gst_element_factory_make ("filesink" , NULL);
if( !gstApp.pipeline ||
!gstApp.src || !gstApp.filter1 ||
!gstApp.encoder || !gstApp.filter2 ||
!gstApp.parser || !gstApp.mp4mux ||
!gstApp.sink )
{
std::cout << "Error creating pipeline elements!" << std::endl;
return false;
}
//Attach elements to pipeline
gst_bin_add_many(
GST_BIN(gstApp.pipeline),
(GstElement*)gstApp.src,
gstApp.filter1,
gstApp.encoder,
gstApp.filter2,
gstApp.parser,
gstApp.mp4mux,
gstApp.sink,
NULL);
//Set pipeline element attributes
g_object_set (gstApp.src, "format", GST_FORMAT_TIME, NULL);
g_object_set (gstApp.src, "is-live", TRUE, NULL);
g_object_set(gstApp.src, "block", TRUE, NULL);
g_object_set(gstApp.src, "is-live", TRUE, NULL);
g_object_set(gstApp.src, "max-bytes",12000000,NULL);
GstCaps *filtercaps1 = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "I420",
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
"framerate", GST_TYPE_FRACTION, FPS, 1,
NULL);
g_object_set (G_OBJECT (gstApp.filter1), "caps", filtercaps1, NULL);
g_object_set(G_OBJECT(gstApp.encoder), "bitrate", 12000000, NULL);
g_object_set(G_OBJECT(gstApp.encoder), "control-rate", 0, NULL);
g_object_set(G_OBJECT(gstApp.encoder), "preset-level", 3, NULL);
GstCaps *filtercaps2 = gst_caps_new_simple ("video/x-h265",
"stream-format", G_TYPE_STRING, "byte-stream",
NULL);
g_object_set (G_OBJECT (gstApp.filter2), "caps", filtercaps2, NULL);
//Link elements together
g_assert( gst_element_link_many(
(GstElement*)gstApp.src,
gstApp.filter1,
gstApp.encoder,
gstApp.filter2,
gstApp.parser,
gstApp.mp4mux,
gstApp.sink,
NULL ) );