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 [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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 <[hidden email]> wrote: I'm trying to query the framerate from a simple Python gstreamer script and _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
It seems to be able to support Gst.Fraction.
I get the following output ... I also included the snippet $ python run_appsink.py GSTSample - constructor width == 640 height == 480 <class 'gi.repository.Gst.Fraction'> An exception occurred Exception ignored in: <module 'threading' from '/Users/josephceli/.pyenv/versions/3.6.1/lib/python3.6/threading.py'> Traceback (most recent call last): File "/Users/josephceli/.pyenv/versions/3.6.1/lib/python3.6/threading.py", line 1296, in _shutdown _main_thread._delete() File "/Users/josephceli/.pyenv/versions/3.6.1/lib/python3.6/threading.py", line 1015, in _delete del _active[get_ident()] KeyError: 123145386319872 ----------------------------------------------------------------------------------------------- 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') print("width == {}".format(width)) height = caps_format.get_value('height') print("height == {}".format(height)) print(Gst.Fraction) try: fps = caps_format.get_value('framerate') print("fps == {}".format(fps)) except: print("An exception occurred") sys.exit() return width, height, fps -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by Thibault Saunier-4
I figured it out.
I should be using fps_fraction = caps_format.get_fraction('framerate') instead of get_value Thank you for your help. Joseph -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |