AppSink方法丢失:AttributeError:'GstAppSink'对象没有属性'is_eos'

时间:2019-02-22 02:45:15

标签: python gstreamer pygobject

我正在尝试使用AppSink接收器从中读取示例,但是对象上似乎不存在任何AppSink方法。

import gi
gi.require_version("Gst", "1.0")

from gi.repository import Gst
Gst.init()

pipe = Gst.parse_launch("audiotestsrc ! opusenc ! appsink name=sink")
sink = pipe.get_by_name("sink")

while not sink.is_eos():
    pass

错误

Traceback (most recent call last):
  File "x.py", line 9, in <module>
    while not sink.is_eos():
AttributeError: 'GstAppSink' object has no attribute 'is_eos'

gstreamer版本:

gst-inspect-1.0 version 1.14.1
GStreamer 1.14.1
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

1 个答案:

答案 0 :(得分:3)

appsink接口与基本GStreamer接口不在同一个库中。您还需要导入GstApp

import gi

gi.require_version("Gst", "1.0")
gi.require_version("GstApp", "1.0")

from gi.repository import Gst, GstApp

Gst.init(None)

pipe = Gst.parse_launch("audiotestsrc ! opusenc ! appsink name=sink")
sink = pipe.get_by_name("sink")

while not sink.is_eos():
    pass