How to get a video 's raw width and height?

forestzhu forest0823 at 126.com
Mon Jul 30 23:05:23 PDT 2012


Hi all,
I am using playbin2 to build the pipleline.
In a case I need to get the raw size of the video will be played.
I tried to use "get-video-pad" signal to get the videopad,but failed.
And than I found 
g_object_get (G_OBJECT (player->pipeline ), "n-video", &n_video, NULL);
return n_video is 0;
But why? The vides is played well,how can n-video of playbin2 be 0?

And can anyone give a hint about how to get a video's raw width and height ?

With thanks!
alex
July 31

Below is my function to get the info of the video:

static void
parse_video_info (PLAYER *player)
{
	GstPad *videopad = NULL;
	int n_video;
	int i = 0;
	g_object_get (G_OBJECT (player->pipeline ), "n-video", &n_video, NULL);
	g_print("n-video:%d",n_video);
	if (n_video > 0)
	{
		for (i = 0; i < n_video && videopad == NULL; i++)
			g_signal_emit_by_name (player->pipeline, "get-video-pad", i, &videopad);
	}

	if (videopad)
	{

		GstCaps *caps;
		if ((caps = gst_pad_get_negotiated_caps (videopad)))
		{
			  GstStructure *s = gst_caps_get_structure (caps, 0);
			  gst_structure_get_int (s, "width", &(player->width));
			  gst_structure_get_int (s, "height", &(player->height));
			  gst_caps_unref (caps);
		}
		gst_object_unref (videopad);
	}
	g_print ("get stream width:%d;height:%d",player->width ,player->height );
}







--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-get-a-video-s-raw-width-and-height-tp4655756.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list