Tool/software: Linux
Hi,
My pipeline is
gst-launch-1.0 -e v4l2src device=/dev/video1 ! 'video/x-raw, format=(string)YUY2, width=(int)640, height=(int)720, framerate=10/1' ! ducatijpegdec ! tee name=t ! queue ! videocrop left = 2016 right=1008 ! videoscale ! video/x-raw , format=NV12 , height=240 , width=320 ! videoconvert ! video/x-raw , format=Y444 ! plugin1 ! fakesink t. ! queue min-threshold-buffers=2 ! ducatih264enc hrd-buffer-size=4064256 rate-preset=1 ! plugin2 ! fakesink
This pipeline works fine. I am going to make application based on this pipeline but it gives segmentation fault while adding elements.
#include <stdio.h>
#include <gst/gst.h>
/* BUS function for ERROR */
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg))
{
case GST_MESSAGE_EOS:
g_print ("End of stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:
{
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_free (debug);
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
/* Main function does atual processing */
int main (int argc , char *argv[])
{
GstElement *pipeline, *video_source, *filter_source, *ducatijpegdec, *tee, *rtsp_queue, *ducatih264enc, *plugin2, *rtsp_sink;
GstElement *ovready_queue, *video_crop, *video_scale, *filter_scale, *video_convert, *filter_convert, *plugin1, *ovready_sink;
GstBus *bus;
GstMessage *msg;
GstPadTemplate *tee_src_pad_template;
GstPad *tee_rtsp_pad, *tee_ovready_pad;
GstPad *queue_rtsp_pad, *queue_ovready_pad;
GstCaps *source_caps, *convert_caps, *scale_caps;
gst_init (&argc, &argv);
/* Create the elements */
video_source = gst_element_factory_make ("v4l2src", "video_source");
filter_source = gst_element_factory_make ("capsfilter", "filter_source");
ducatijpegdec = gst_element_factory_make ("ducatijpegdec", "ducatijpegdec");
tee = gst_element_factory_make ("tee", "tee");
/* ovready thread */
ovready_queue = gst_element_factory_make ("queue", "ovready_queue");
video_crop = gst_element_factory_make ("videocrop", "video_crop");
video_scale = gst_element_factory_make ("videoscale", "video_scale");
filter_scale = gst_element_factory_make ("capsfilter", "filter_scale");
video_convert = gst_element_factory_make ("videoconvert", "video_convert");
filter_convert= gst_element_factory_make ("capsfilter", "filter_convert");
plugin1 = gst_element_factory_make ("plugin1", "plugin1");
ovready_sink = gst_element_factory_make ("fakesink", "ovready_sink");
/* rtsp thread */
rtsp_queue = gst_element_factory_make ("queue", "rtsp_queue");
ducatijpegdec = gst_element_factory_make ("ducatih264enc", "ducatih264enc");
plugin2 = gst_element_factory_make ("plugin2", "plugin2");
rtsp_sink = gst_element_factory_make ("fakesink", "rtsp_sink");
/* source_caps*/
source_caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "YUY2",
"width", G_TYPE_INT, 640,
"height", G_TYPE_INT, 720,
"framerate", G_TYPE_FLOAT, 15/1,
NULL);
/* Set up elements for source_caps*/
g_object_set (G_OBJECT (filter_source), "caps", source_caps, NULL);
gst_caps_unref (source_caps);
g_object_set (G_OBJECT (video_source), "device", "/dev/video1", NULL);
/* scale_caps */
scale_caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "NV12",
"width", G_TYPE_INT, 320,
"height", G_TYPE_INT, 240,
NULL);
/* Set up elements for scale_caps*/
g_object_set (G_OBJECT (filter_scale), "caps", scale_caps, NULL);
gst_caps_unref (scale_caps);
/* convert_caps */
convert_caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "Y444",
"width", G_TYPE_INT, 320,
"height", G_TYPE_INT, 240,
NULL);
/* Set up elements for convert_caps */
g_object_set (G_OBJECT (filter_convert), "caps", convert_caps, NULL);
gst_caps_unref (convert_caps);
/* Set up elements for rtsp_queue */
g_object_set (G_OBJECT (rtsp_queue), "min-threshold-buffers", 2, NULL);
/* Set up elements for ducatih264enc */
g_object_set (G_OBJECT (ducatih264enc), "rate-preset", 1, NULL);
/* Set up elements for video_crop */
g_object_set (G_OBJECT (video_crop), "left", 2016, NULL);
/* Set up elements for video_crop */
g_object_set (G_OBJECT (video_crop), "right", 1008, NULL);
/* Create the empty pipeline */
pipeline = gst_pipeline_new ("test-pipeline");
if (!pipeline || !video_source || !filter_source || !ducatijpegdec || !tee || !ovready_queue || !video_crop || !video_scale || !filter_scale || !video_convert || !filter_convert || !plugin1 || !ovready_sink || !rtsp_queue || !ducatih264enc || !plugin2 || !rtsp_sink)
{
g_printerr ("Not all elements could be created.\n");
return -1;
}
/* Link all elements that can be automatically linked because they have "Always" pads */
gst_bin_add_many (GST_BIN (pipeline), video_source, ducatijpegdec, tee, ovready_queue, video_crop, video_scale, video_convert, plugin1, ovready_sink, rtsp_queue, ducatih264enc, plugin2, rtsp_sink, NULL);
if (gst_element_link_many (video_source, ducatijpegdec, tee, NULL) != TRUE ||gst_element_link_many (ovready_queue, video_crop, video_scale, video_convert, plugin1, ovready_sink, NULL) != TRUE || gst_element_link_many (rtsp_queue, ducatih264enc, plugin2, rtsp_sink, NULL) != TRUE)
{
g_printerr ("Elements could not be linked.\n");
gst_object_unref (pipeline);
return -1;
}
/* Manually link the Tee, which has "Request" pads */
tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (tee), "src_%d");
tee_ovready_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name (tee_ovready_pad));
queue_ovready_pad = gst_element_get_static_pad (ovready_queue, "sink");
tee_rtsp_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);
g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name (tee_rtsp_pad));
queue_rtsp_pad = gst_element_get_static_pad (rtsp_queue, "sink");
if (gst_pad_link (tee_ovready_pad, queue_ovready_pad) != GST_PAD_LINK_OK || gst_pad_link (tee_rtsp_pad, queue_rtsp_pad) != GST_PAD_LINK_OK)
{
g_printerr ("Tee could not be linked.\n");
gst_object_unref (pipeline);
return -1;
}
gst_object_unref (queue_ovready_pad);
gst_object_unref (queue_rtsp_pad);
/* Start playing the pipeline */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
/* Release the request pads from the Tee, and unref them */
gst_element_release_request_pad (tee, tee_ovready_pad);
gst_element_release_request_pad (tee, tee_rtsp_pad);
gst_object_unref (tee_ovready_pad);
gst_object_unref (tee_rtsp_pad);
/* Free resources */
if (msg != NULL)
{
gst_message_unref (msg);
}
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
Attached my application. Give me some solution regarding issue.
Regards,
Prerak
