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

Stefan Sauer ensonic at hora-obscura.de
Sun Aug 5 02:37:20 PDT 2012


On 07/31/2012 08:05 AM, forestzhu wrote:
> 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 ?
The code below is not a standalone runable example. We don't know when
and how it is called. Once issue could be that you call this too early
(the fact that your getting n_video=0 is supporting that assumtion). The
pipeline should be in >=paused state the return meaningful results.

Stefan
>
> 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.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list