我已经解决了这个问题。使用此页面帮助
以下代码
GstElement *filesrc, *demux, *decoder, *sink;
static void
cb_new_pad (GstElement *element,
GstPad *pad,
gpointer data)
{
gchar *name;
name = gst_pad_get_name (pad);
if (strcmp (name, "video_0") == 0 &&
!gst_element_link_pads(demux, name, decoder, "sink")) {
printf("link demux-decoder fail\n");
}
g_free (name);
}
static void
pipeline_init(char *data)
{
filesrc = gst_element_factory_make ("filesrc", "filesrc");
demux = gst_element_factory_make ("qtdemux", "qtdemux");
decoder = gst_element_factory_make ("vaapidecode", "decoder");
sink = gst_element_factory_make ("vaapisink", "sink");
if (!filesrc || !demux || !decoder || !sink)
return;
g_object_set (G_OBJECT (filesrc), "location", data, NULL);
if (!gst_element_link(filesrc, demux)) {
printf("link filesrd--demux fail\n");
return;
}
if (!gst_element_link(decoder, sink)) {
printf("link decoder--sink fail\n");
return;
}
g_signal_connect (demux, "pad-added", G_CALLBACK (cb_new_pad), NULL);
}