我是GObject,GStreamer,GI等的新手.我的mac跑得很高.
虽然我能够成功地运行测试音频文件,如下所示。
gst-launch-1.0 filesrc location=test.mp3 ! decodebin ! audioconvert ! autoaudiosink
我无法在python代码中进行模拟。
它正在返回以下错误
python ccc.py
<Gst.Message object at 0x10ebb59a8 (GstMessage at 0x7fde5688b740)>
<flags GST_MESSAGE_ERROR of type Gst.MessageType>
(gerror=GLib.Error('Internal data stream error.', 'gst-stream-error-quark', 1), debug='gstbaseparse.c(3611): void gst_base_parse_loop(GstPad *) (): /GstPipeline:pipeline0/GstDecodeBin:decodebin/GstMpegAudioParse:mpegaudioparse0:\nstreaming stopped, reason not-linked (-1)')码
#!/usr/bin/python
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GLib, GObject
from gi.repository import Gst as gst
#Initialize Go Objects
GObject.threads_init()
gst.init(None)
# Create the pipeline for our elements.
pipe = gst.Pipeline()
source = gst.ElementFactory.make("filesrc", "file-source")
source.set_property("location", "test.wav")
decoder = gst.ElementFactory.make("decodebin","decodebin")
converter = gst.ElementFactory.make("audioconvert","audioconvert")
audiosink = gst.ElementFactory.make("autoaudiosink", "audiosink")
# Ensure all elements were created successfully.
if (not pipe or not source or not decoder or not audiosink):
print('Not all elements could be created.')
exit(-1)
#Add elements to pipeline
pipe.add(source)
pipe.add(decoder)
pipe.add(converter)
pipe.add(audiosink)
#Link our elements together.
source.link(decoder)
decoder.link(converter)
converter.link(audiosink)
# Set our pipelines state to Playing.
pipe.set_state(gst.State.PLAYING)
# Wait until error or EOS.
bus = pipe.get_bus()
msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE,gst.MessageType.ERROR | gst.MessageType.EOS)
print msg
print msg.type
print msg.parse_error()
# Free resources.
pipe.set_state(gst.State.NULL)有什么指示吗?谢谢。
发布于 2018-10-30 08:39:05
尝试使用Gst.parse_launch,以与命令行相同的方式直接输入完整的管道。
例:
PIPE = """ filesrc location=test.mp3 ! decodebin ! audioconvert ! autoaudiosink """然后:
pipeline = Gst.parse_launch(PIPE)这比单独添加并将它们连接到管道要容易得多。
https://stackoverflow.com/questions/53037244
复制相似问题