Why the video not play when I link decodebin with xvimagsink?
DBOYaoao
yiikai1987910 at gmail.com
Sat Jun 8 20:17:38 PDT 2013
HI ALL:
I use decodebin2 's dynmic pad to link with xvimagesink,but the video
not play,I only see the first frame of file!
This is the code:
void cb_newpad (GstElement* decodebin,GstPad* pad,gpointer user_data)
{
printf("add new pad\n");
GstPad *audiopad;
GstPad *videopad;
GstCaps *caps;
GstStructure *str;
audiopad = gst_element_get_static_pad (audiosink, "sink");
if (GST_PAD_IS_LINKED (audiopad)) {
printf("audio has linked\n");
g_object_unref (audiopad);
return;
}
videopad = gst_element_get_static_pad (videosink, "sink");
if (GST_PAD_IS_LINKED (videopad)) {
printf("video has linked\n");
g_object_unref (videopad);
return;
}
//caps = gst_pad_query_caps(pad, NULL);
//
caps = gst_pad_get_caps(pad);
str = gst_caps_get_structure (caps, 0);
if (g_strrstr (gst_structure_get_name (str), "audio")) {
gst_caps_unref (caps);
if(gst_pad_link (pad, audiopad) != 0)
{
printf("link video error\n");
}
gst_object_unref (audiopad);
}
else if(g_strrstr (gst_structure_get_name (str), "video"))
{
gst_caps_unref (caps);
if(gst_pad_link(pad,videopad) !=0)
{
printf("link video error\n");
}
gst_object_unref (videopad);
}
#if 0
gst_caps_unref (caps);
gst_object_unref (audiopad);
return;
gst_caps_unref (caps);
#endif
}
int main(int argc,char **argv)
{
gst_init(&argc,&argv);
loop = g_main_loop_new(NULL, FALSE);
pipeline = gst_pipeline_new ("video-player");
src = gst_element_factory_make("filesrc", "file-source");
decode = gst_element_factory_make("decodebin2", "video-dec");
g_signal_connect (decode, "pad-added", G_CALLBACK (cb_newpad), NULL);
videosink = gst_element_factory_make("xvimagesink", "video-output");
audiosink = gst_element_factory_make("alsasink","audio-output");
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
if (!pipeline || !src || !decode || !videosink || !audiosink ) {
g_printerr ("One element could not be created. Exiting.\n");
return -1;
}
g_object_set (G_OBJECT (src), "location", argv[1], NULL);
gst_bin_add_many (GST_BIN (pipeline),src, decode, videosink,audiosink,
NULL);
if(!gst_element_link (src, decode))
{
printf("link src and decode error\n");
return 0;
}
// gst_element_link_many (src,decode,NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running...\n");
g_main_loop_run (loop);
return 0;
}
Thanks for your help!!
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Why-the-video-not-play-when-I-link-decodebin-with-xvimagsink-tp4660445.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list