capsfilter in videomixer

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

capsfilter in videomixer

bboyavatar
I use the following pipeline to make two videos mixed successfully
"gst-launch -v videomixer name=mix ! ffmpegcolorspace ! xvimagesink filesrc location=foreman.264 ! h264parse ! ffdec_h264 ! videoscale ! video/x-raw-yuv, width=352, height=288 ! ffmpegcolorspace ! videobox ! mix. filesrc location=foreman1.264 ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! videobox border-alpha=0 alpha=1 top=-288 bottom=0 left=-352 ! mix."

I try to translate this pipeline into C code. It does not work well.
<nabble_embed> #include&lt;gst/gst.h&gt; #include<glib.h> #include<stdio.h> /* gst-launch videomixer name=mix ! ffmpegcolorspace ! xvimagesink filesrc location=foreman.264 ! h264parse ! ffdec_h264 ! videoscale ! video/x-raw-yuv, width=352, height=288 ! ffmpegcolorspace ! videobox ! mix. filesrc location=foreman1.264 ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! videobox border-alpha=0 alpha=1 top=-288 bottom=0 left=-352 ! mix. */ 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 *err; gst_message_parse_error (msg, &err, &debug); g_free (debug); g_print ("Error: %s\n", err->message); g_error_free (err); g_main_loop_quit (loop); break; } default: break; } return TRUE; } int main(int argc,char *argv[]) { GMainLoop *loop; GstElement *pipeline,*mixer,*colorspace,*imagesink,*filesrc1,*h264parse1,*h264dec1,*colorspace1,*videobox1,*filesrc2,*h264parse2,*h264dec2,*colorspace2,*videobox2; GstElement *videoscale1,*capsfilter1; GstCaps *caps; GstBus *bus; gst_init(&argc, &argv); caps = gst_caps_new_simple ("video/x-raw-yuv", "width", G_TYPE_INT, 352, "height", G_TYPE_INT, 288, NULL); capsfilter1=gst_element_factory_make("capsfilter","capsfilter1"); g_object_set(G_OBJECT(capsfilter1),"caps",caps,NULL); gst_caps_unref (caps); mixer = gst_element_factory_make ("videomixer", "mixer"); colorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace"); imagesink = gst_element_factory_make ("xvimagesink", "imagesink"); filesrc1 = gst_element_factory_make ("filesrc", "filesrc1"); g_object_set (G_OBJECT (filesrc1), "location", "foreman.264", NULL); h264parse1 = gst_element_factory_make ("h264parse", "h264parse1"); h264dec1 = gst_element_factory_make ("ffdec_h264", "h264dec1"); colorspace1 = gst_element_factory_make ("ffmpegcolorspace", "colorspace1"); videobox1 = gst_element_factory_make ("videobox", "videobox1"); g_object_set (G_OBJECT (videobox1), "top", 0, NULL); g_object_set (G_OBJECT (videobox1), "bottom", 0, NULL); g_object_set (G_OBJECT (videobox1), "left", 0, NULL); videoscale1=gst_element_factory_make("videoscale","videoscale1"); g_assert (videoscale1 != NULL); filesrc2 = gst_element_factory_make ("filesrc", "filesrc2"); g_object_set (G_OBJECT (filesrc2), "location", "foreman1.264", NULL); h264parse2 = gst_element_factory_make ("h264parse", "h264parse2"); h264dec2 = gst_element_factory_make ("ffdec_h264", "h264dec2"); colorspace2 = gst_element_factory_make ("ffmpegcolorspace", "colorspace2"); videobox2 = gst_element_factory_make ("videobox", "videobox2"); g_object_set (G_OBJECT (videobox2), "top", -288, NULL); g_object_set (G_OBJECT (videobox2), "bottom", 0, NULL); g_object_set (G_OBJECT (videobox2), "left", -352, NULL); loop = g_main_loop_new (NULL, FALSE); pipeline = gst_pipeline_new ("my_pipeline"); gst_bin_add_many(GST_BIN (pipeline),mixer,colorspace,imagesink,NULL); gst_element_link_many (mixer, colorspace, imagesink, NULL); gst_bin_add_many(GST_BIN (pipeline),filesrc1,h264parse1,h264dec1,videoscale1,capsfilter1,colorspace1,videobox1,NULL); //gst_bin_add_many (GST_BIN (pipeline),imagesink,filesrc1,h264parse1,h264dec1,videoscale1,capsfilter1,colorspace1); //gst_element_link_many(filesrc1, h264parse1,h264dec1,videoscale1,capsfilter1,colorspace1,imagesink); gst_element_link(filesrc1, h264parse1); gst_element_link(h264parse1,h264dec1); gst_element_link(h264dec1,colorspace1); gst_element_link(colorspace1,videoscale1); gst_element_link(videoscale1,capsfilter1); gst_element_link(capsfilter1,videobox1); gst_element_link(videobox1,mixer); gst_bin_add_many(GST_BIN (pipeline),filesrc2,h264parse2,h264dec2,colorspace2,videobox2,NULL); gst_element_link(filesrc2, h264parse2); gst_element_link(h264parse2,h264dec2); gst_element_link(h264dec2,colorspace2); gst_element_link(colorspace2,videobox2); gst_element_link(videobox2,mixer); //gst_element_link_many (filesrc1, h264parse1,h264dec1,videoscale1,capsfilter1,colorspace1,videobox1,mixer); //gst_element_link_many (filesrc2, h264parse2,h264dec2,colorspace2,videobox2,mixer); bus = gst_pipeline_get_bus (GST_PIPELINE(pipeline)); gst_bus_add_watch (bus, bus_call, loop); g_object_unref (bus); gst_element_set_state (pipeline, GST_STATE_PLAYING); g_main_loop_run (loop); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (pipeline)); g_main_loop_unref (loop); return 0; } </nabble_embed>

Can anyone tell me what is wrong? Thanks!