Python-gst - >列出元素的所有属性

时间:2017-12-11 19:58:26

标签: gstreamer python-gstreamer pygst

如果可能重新接收Element所具有的所有元素属性? 我可以列出元素,但我不知道(也是在阅读文档后) 我如何访问这些属性。

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()

目标是将属性和元素信息转换为json格式,如:

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

谢谢大家

1 个答案:

答案 0 :(得分:0)

您正在寻找的功能是g_object_class_list_properties(),它会为您提供每个元素支持的属性列表。例如

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'>]

这也是gst-inspect-1.0的作用。请参阅the code