gstreamer:遇到一般流错误

时间:2016-06-23 08:08:21

标签: gstreamer

现在我正在尝试播放mp4文件。 尝试将mp4文件播放到demux后,会发生流错误。 我的代码如下,如果有任何问题,请告诉我。

有什么建议吗?谢谢

错误 - >遇到一般流错误

int main(int argc, char* argv[]){

    GMainLoop *loop;
    GstElement *pipeline, *vsource, *demux, *vqueue, *ssource, *muxer, *filesink;
    GstElement *vplay, *conv;
    //GstBin *recording;
    GstBus *bus;
    GstPad *srcpad, *sinkpad;
    guint bus_watch_id;


    gst_init (&argc, &argv);
    loop = g_main_loop_new (NULL, FALSE);

    pipeline        = gst_pipeline_new("Live Recording");
    vsource         = gst_element_factory_make("filesrc","v-file-source");
    demux           = gst_element_factory_make("qtdemux","v-file-demux");
    vqueue          = gst_element_factory_make("queue2","v-file-queue");
    vplay           = gst_element_factory_make("autovideosink","play");
    conv            = gst_element_factory_make("videoconvert","converter");
    if(!pipeline)
            g_print("no pipe\n");
    if(!vsource)
            g_print("no video source\n");
    if(!demux)
            g_print("no video demux\n");
    if(!vqueue)
            g_print("no video queue\n");
    if(!vplay)
            g_print("no video play\n");
    if(!conv)
            g_print("no conv");

    g_object_set (G_OBJECT (vsource), "location", "./sample.mp4", NULL);

    bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));

    bus_watch_id = gst_bus_add_watch(bus, bus_call, loop);
    gst_object_unref(bus);
    gst_bin_add_many(GST_BIN(pipeline),vsource,demux,vqueue, conv, vplay,NULL);
    if(!gst_element_link(vsource, demux)){
            g_print("no link");
    }
    if(!gst_element_link_many(vqueue, conv, vplay,NULL)){
            g_print("no link many");
    }
    g_print("now play\n");

    g_signal_connect (demux, "pad-added", G_CALLBACK (on_pad_added), vqueue);
    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_source_remove(bus_watch_id);
    g_main_loop_unref(loop);
    return 0;
}

0 个答案:

没有答案