Python-gst -> List All Properties of an Element

2.4k views Asked by At

If it possbile to recive all element properties that a Element has? I can list the elements but I dont know (also after reading docs) how I can access the properties.

from gi.repository import Gst
Gst.init()
reg = Gst.Registry.get()

for x in reg.get_plugin_list():
     print x.get_name(), x.get_version()

The goal is to convert the properties and the element information into a json format like:

{
    "name": <plugin-name>,
    "version": <plugin-version>
    "properties": {
        "<property-key>": {
            "desc": <propertie-desc>,
            "value": <propertie-value>,
            "data-type": <propertie-type>,
         }
     }
}

Thank you Guys

1

There are 1 answers

2
ystreet00 On BEST ANSWER

The function you're looking for is g_object_class_list_properties() which will give you list of properties supported by each element. e.g.

import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GObject
Gst.init([])
e = Gst.ElementFactory.make("identity", None)
e.list_properties()
[<GParamString 'name'>, <GParamObject 'parent'>, <GParamBoolean 'qos'>, <GParamUInt 'sleep-time'>, <GParamInt 'error-after'>, <GParamFloat 'drop-probability'>, <GParamFlags 'drop-buffer-flags'>, <GParamInt 'datarate'>, <GParamBoolean 'silent'>, <GParamBoolean 'single-segment'>, <GParamString 'last-message'>, <GParamBoolean 'dump'>, <GParamBoolean 'sync'>, <GParamInt64 'ts-offset'>, <GParamBoolean 'check-imperfect-timestamp'>, <GParamBoolean 'check-imperfect-offset'>, <GParamBoolean 'signal-handoffs'>]

This is also what gst-inspect-1.0 does as well. See the code.