I am trying to use Gstreamer with python bindings in order to search for available cameras on my system. As a result I would like to obtain a list of devices with their corresponding capabilities (width, height, framerate...).
Gstreamer offers very useful class called Gst.DeviceMonitor to obtain available devices. However, I ran into problems when tying to extract capabilities from the discovered devices. Concretely, I only have troubles with obtaining capabilities "pixel-aspect-ratio" and "framerate", which are both of Gst.Fraction type.
Here is a minimal code example:
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
Gst.init(None)
caps = Gst.Caps.from_string('video/x-h264,width=640,height=480,framerate={30/1, 20/1, 15/1, 1/1}')
structure = caps.get_structure(0)
width = structure.get_int('width').value
height = structure.get_int('height').value
framerates = structure.get_list('framerate').array
print('width = ', width)
print('height = ', height)
for i in range(framerates.n_values):
print(' - framerate = ', framerates.get_nth(i))
The following exception is thrown on the last line:
TypeError: unknown type GstFraction
I have found here that someone had similar issue in 2012, but I have not found any solutions. Does anybody have any suggestion?
PS: I am using Python 3.5.5
and Gstreamer 1.14.5
.