如何使用videomixer元素进行gstreamer?

时间:2014-04-23 03:45:51

标签: gstreamer

我想使用gstreamer播放两个本地视频文件,但是我收到错误:分段错误它来自 libgstvideomixer.so 。我的代码出了什么问题?播放两个视频需要视频混合器元素。我应该使用视频文件吗?

gst-launch --no-fault filesrc location = / mnt / upan / source.264!排队!打字! ffdec_h264! videomixer name = mix! xvimagesink sync = false filesrc location = / mnt / upan / source.264!排队!打字! ffdec_h264!混合。

static void p_gst_init(void)
{
    App *app = &s_app;      
    GError *error = NULL;
    GstBus *bus;
    GstElement  *parse, *decoder, *queue;
    GstElement  *parse2, *decoder2, *queue2;

    gst_init (NULL, NULL);      

    /* create a mainloop to get messages */
    app->loop = g_main_loop_new (NULL, TRUE);
    app->playbin = gst_pipeline_new ("pipeline");
    app->appsrc = gst_element_factory_make ("filesrc", "disk_source");
    g_object_set (G_OBJECT (app->appsrc), "location", "/mnt/upan/test.264", NULL);
queue = gst_element_factory_make ("queue", "queue");
    parse = gst_element_factory_make ("typefind", "parse");
    decoder = gst_element_factory_make ("ffdec_h264", "decoder");
    GstElement *filesrc2;
    filesrc2 = gst_element_factory_make ("filesrc", "disk_source2");
    g_object_set (G_OBJECT (appsrc2), "location", "/mnt/upan/source.264", NULL);
    queue2 = gst_element_factory_make ("queue", "queue2");
    parse2 = gst_element_factory_make ("typefind", "parse2");
    decoder2 = gst_element_factory_make ("ffdec_h264", "decoder2");
    /*
    GstElement * videobox;
    videobox = gst_element_factory_make("videobox", NULL);
    g_object_set (videobox, "alpha", 0, "border-alpha", 0, "bottom", 100, "left", 100, "right", 100, "top", 100, NULL);
    */
    GstElement * videomixer;
    videomixer = gst_element_factory_make("videomixer","videomixer");
    app->xvimagesink = gst_element_factory_make ("xvimagesink", "play_video");
    g_object_set (G_OBJECT (app->xvimagesink), "synchronous", FALSE, NULL);

    gst_bin_add_many (GST_BIN (app->playbin), app->appsrc, queue, parse, decoder, videomixer, app->xvimagesink, filesrc2, queue2, parse2, decoder2, NULL);
    if(gst_element_link_many (app->appsrc, queue, parse, decoder, videomixer, NULL))
    {
        printf("---------link element success-----------------\n");
    }
    else
        printf("---------link element failed-----------------\n");

    gst_element_link_many (filesrc2, queue2, parse2, decoder2, videomixer, NULL);
    gst_element_link_many(videomixer, app->xvimagesink, NULL);

    bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));
    gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
    gst_bus_set_sync_handler(bus, (GstBusSyncHandler)create_window, app);

    g_signal_connect (app->appsrc, "need-data", G_CALLBACK (feed_data), app);
    return ;
}

0 个答案:

没有答案