Querying framerate in Python
joseph
joseph.celi at jci.com
Tue Jul 21 20:45:09 UTC 2020
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/
More information about the gstreamer-devel
mailing list