파이썬으로 gstreamer 응용 프로그램을 연결합니다.파이썬 gst.LinkError 문제 Gstreamer
import pygst
pygst.require('0.10')
import gst
import pygtk
pygtk.require('2.0')
import gtk
# this is very important, without this, callbacks from gstreamer thread
# will messed our program up
gtk.gdk.threads_init()
def main():
pipeline = gst.Pipeline('pipleline')
filesrc = gst.element_factory_make("filesrc", "filesrc")
filesrc.set_property('location', 'C:/a.mp3')
decode = gst.element_factory_make("decodebin", "decode")
convert = gst.element_factory_make('audioconvert', 'convert')
sink = gst.element_factory_make("autoaudiosink", "sink")
pipeline.add(filesrc, decode, convert, sink)
gst.element_link_many(filesrc, decode, convert, sink)
pipeline.set_state(gst.STATE_PLAYING)
gtk.main()
main()
그리고 오류 : 그리고 난 다음 코드를 사용하여 LinkError 얻을 그것은 매우 이상하다
ImportError: could not import gio
Traceback (most recent call last):
File "H:\workspace\ggg\src\test2.py", line 37, in <module>
main()
File "H:\workspace\ggg\src\test2.py", line 31, in main
gst.element_link_many(filesrc, decode, convert, sink)
gst.LinkError: failed to link decode with convert
, 같은 파이프 라인을하지만, parse_launch로 구축, 그것을 작동합니다. 여기에 코드가 있습니다 :
import pygst
pygst.require('0.10')
import gst
import pygtk
pygtk.require('2.0')
import gtk
# this is very important, without this, callbacks from gstreamer thread
# will messed our program up
gtk.gdk.threads_init()
def main():
player = gst.parse_launch('filesrc location=C:/a.mp3 ! decodebin ! audioconvert ! autoaudiosink')
player.set_state(gst.STATE_PLAYING)
gtk.main()
main()
여기에 질문 하나, 왜 수동 하나가 실패했지만 파싱 된 하나의 성공? 그게 뭐가 잘못 됐니? 어떻게 해결할 수 있습니까?
감사합니다.
레코드의 경우 "ImportError : gio를 가져올 수 없습니다"라는 오류가 표시되지 않습니다. 나는 나머지 부분을 얻는다. 아래를 보라. –