how to get framerate of video from caps?

classic Classic list List threaded Threaded
1 message Options
ms
Reply | Threaded
Open this post in threaded view
|

how to get framerate of video from caps?

ms
This post was updated on .
i have a pipeline:
appsrc -> h264parse -> decodebin -> videoscale -> xvimagesink
i wanna get framerate of video when data is probed in videoscale. My source code like this:

GstElement* video_conv = gst_element_factory_make("videoscale", "video converter");
GstPad* pad = gst_element_get_pad(video_conv);
gst_pad_add_buffer_probe(pad, G_CALLBACK(have_data_cb), NULL);

static void have_data_cb(GstPad* pad, GstBuffer* buffer, gpointer user_data)
{
        gint num, denom;
        GstCaps* cap = gst_pad_get_caps(pad);
        gst_video_parse_caps_framerate(cap, &num, &denom);
        printf("num: %d, denom: %d\n", num, denom);
        gst_caps_to_string(caps);
}

result:
num: -1236404188, denom: 15999180
caps: video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[ 1, 2048 ], height=(int)[ 1, 2048 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[ 1, 32767 ], height=(int)[ 1, 32767 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)UYVY, width=(int)[ 1, 2048 ], height=(int)[ 1, 2048 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)UYVY, width=(int)[ 1, 32767 ], height=(int)[ 1, 32767 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)I420, width=(int)[ 1, 2048 ], height=(int)[ 1, 2048 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)I420, width=(int)[ 1, 32767 ], height=(int)[ 1, 32767 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YV12, width=(int)[ 1, 2048 ], height=(int)[ 1, 2048 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YV12, width=(int)[ 1, 32767 ], height=(int)[ 1, 32767 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

when i used gst_caps_to_string(caps), i have gotten: framerate = (fraction)[ 0/1, 2147483647/1 ], but when i used gst_video_parse_caps_framerate i have gotten wrong result. Please explain for me!