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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

forestzhu
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 );
}



Reply | Threaded
Open this post in threaded view
|

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

forestzhu
Anyone knows about this?
Reply | Threaded
Open this post in threaded view
|

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

Stefan Sauer
In reply to this post by forestzhu
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
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

forestzhu
H Stefan,

I put this func in a loop ,and then I get the right result.
Thank you !

alex
Aug 7