[gst-devel] need help about my first video test application

Andoni Morales ylatuya at gmail.com
Mon Jun 1 02:02:50 CEST 2009


2009/5/31 Favor Tang <tangher at gmail.com>:
> hi.
>
>    sorry for this question of a newbie. I am a beginner into
> gstreamer, and wanna write a application for video playing. I didn't
> found a simple example about video.
> I modified the audio play example. I can't get the video on screen,
> what's the problem? I doubt if I create the pipeline correctly.

You are linking both the audio stream and the video stream to the
'decoder' element wich is an audio decoder.
In the 'on_pad_added' callback you need to read the caps of the new
pad and link it to the correct element. If it's a video stream you
will link it to the video decoder and if it's an audio stream you need
to link it to the audio decoder. This example shows you how to check
from the caps the media type and link the demuxer new pad to the
appropiate element:

GstCaps *caps=NULL;
GstStructure *str =NULL;
GstPad *newpad=NULL;


 /* check media type */
caps = gst_pad_get_caps (pad);
str = gst_caps_get_structure (caps, 0);	
	
if (g_strrstr (gst_structure_get_name (str), "video")){

	newpad = gst_element_get_compatible_pad (videodec, pad, NULL);
	/* only link once */
	if (GST_PAD_IS_LINKED (newpad)) {
    		g_object_unref (newpad);
    		gst_caps_unref (caps);
    		return;
  	}
  		
  	/* link 'n play*/
  	GST_INFO ("Found video stream.");
    	gst_pad_link (pad,newpad);    	
	g_object_unref (newpad);
}
if (g_strrstr (gst_structure_get_name (str), "audio")){

	newpad = gst_element_get_compatible_pad (decoder, pad, NULL);
	/* only link once */
	if (GST_PAD_IS_LINKED (newpad)) {
    		g_object_unref (newpad);
    		gst_caps_unref (caps);
    		return;
  	}
  		
  	/* link 'n play*/
  	GST_INFO ("Found audio stream.");
    	gst_pad_link (pad,newpad);    	
	g_object_unref (newpad);
}


BTW, you can also use the playbin element.


>
> I got error like below:
>
> Running....
> Dynamic pad created, linking demuxer/decoder
> Dynamic pad created, linking demuxer/decoder
> Error: Internal data streame error.
> Retured, stopping playback
> deleting pipeline
>
> and I attached my source file, hope this can help you to figure out
> what I am doing wrong.
> besides, can you give me an example about how to write program for
> video playing?
>
> any help is highly appreciated!
>
> thanks
>
> --
> ~~~~~~~~~~~~~~~~~
>  /favor
> ~~~~~~~~~~~~~~~~~
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>




More information about the gstreamer-devel mailing list