Querying framerate in Python

Thibault Saunier tsaunier at gnome.org
Wed Jul 22 00:45:43 UTC 2020


Hello,

There is clearly something wrong with your gst-python installation. What
does `print(Gst.Fraction)` do? It should print:

                      `<class 'gi.overrides.Gst.Fraction>`

- Thibault

On Tue, Jul 21, 2020 at 6:38 PM joseph <joseph.celi at jci.com> wrote:

> I'm trying to query the framerate from a simple Python gstreamer script and
> seeing the following error
>
> TypeError: unknown type GstFraction
>
> I'm getting the same error on Ubuntu and Mac.  Here is the code snippet
> attempting to get the framerate
>
>
>     def get_frame_res(self, sample):
>         caps_format = sample.get_caps().get_structure(0)
>         frmt_str = caps_format.get_value('format')
>         video_format = GstVideo.VideoFormat.from_string(frmt_str)
>         width = caps_format.get_value('width')
>         height = caps_format.get_value('height')
>         fps = caps_format.get_value('framerate')
>         return width, height, fps
>
>
> The above method is called from my on_buffer method when I receive the
> first
> sample
>
> def on_buffer(self, sink: GstApp.AppSink, data: typ.Any) -> Gst.FlowReturn:
>         sample = sink.emit("pull-sample")
>         if self.frame_num == 0:
>             w, h, fps = self.get_frame_res(sample)
>             print("width::height::fps == {}:{}".format(w,h,fps))
>
> I have read through a lot of posts about installing the correct version of
> python-gst but nothing was able to allow me to get past the TypeError for
> GstFraction
> (ex. sudo apt-get install python-gst-1.0)
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20200721/ad3b0117/attachment-0001.htm>


More information about the gstreamer-devel mailing list