我试图尽快从jackaudiosrc
中获得28个频道
当我连接一个deinterleave
元素时,源代码将会回归
2通道设置,无需任何通道掩码。我的尝试
设置通道掩码是徒劳的。
以下是发生的事情:
potential caps: audio/x-raw-float, endianness=(int)1234, width=(int)32, rate=(int)48000, channels=(int)[ 1, 28 ]
filter caps: audio/x-raw-float, channels=(int)28, channel-positions=(GstAudioChannelPosition)< GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE, GST_AUDIO_CHANNEL_POSITION_NONE >
actual caps: audio/x-raw-float, endianness=(int)1234, width=(int)32, rate=(int)48000, channels=(int)2, channel-positions=(GstAudioChannelPosition)< GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT >
以下是产生该输出的Python代码:
import pygst
pygst.require("0.10")
import gst
import gobject
import gst.audio
gobject.threads_init()
pipeline = gst.Pipeline("mypipeline")
src = gst.element_factory_make("jackaudiosrc", "jacksrc")
pipeline.add(src)
srcpad = src.get_pad("src")
pipeline.set_state(gst.STATE_PLAYING)
print 'potential caps:',srcpad.get_caps()
sink = gst.element_factory_make("fakesink", "sink")
pipeline.add(sink)
filtercaps = gst.caps_from_string("audio/x-raw-float,channels=28")
filtercaps[0].set_value("channel-positions", tuple([gst.audio.AUDIO_CHANNEL_POSITION_NONE]*28))
print "filter caps:",filtercaps
src.link_filtered(sink, filtercaps)
pipeline.set_state(gst.STATE_PLAYING)
print 'actual caps:',srcpad.get_negotiated_caps()
#gst.DEBUG_BIN_TO_DOT_FILE_WITH_TS(pipeline, gst.DEBUG_GRAPH_SHOW_ALL, 'caps')
我还尝试直接设置输出的上限而不是使用 过滤,但也没有做任何事情。
这是最后一个bin-to-dot-file行的输出(点击放大)。
这里&#39; sa gst-launch
行没有实际的多声道音频设置,但不实际上重现错误,我相信因为interleave
元素设置了NONE默认情况下,jackaudiosrc
没有正确限制。也许它仍然可以帮助人们解决这个问题,由于技术限制,他们无法自己复制它。感谢http://tristanswork.blogspot.de/2008/08/multichannel-audio-with-gstreamer.html我改编的原始发射线。
gst-launch-0.10 interleave name=i ! audioconvert ! audioresample ! queue ! deinterleave name=o audiotestsrc ! audioconvert ! queue ! i. audiotestsrc ! audioconvert ! queue ! i. audiotestsrc ! audioconvert ! queue ! i. o. ! queue ! fakesink dump=true o. ! queue ! fakesink dump=true o. ! queue ! fakesink dump=true
编辑:我现在尝试在GStreamer 1.x中做同样的事情。我不再接受tuple
数据类型,因此,在查看其他人直接向get_caps_from_string
函数写入频道位置后,我想出了什么。
from gi.repository import GObject, Gst, GstAudio
GObject.threads_init()
Gst.init(None)
pipeline = Gst.Pipeline("mypipeline")
src = Gst.ElementFactory.make("jackaudiosrc", "jacksrc")
pipeline.add(src)
srcpad = src.get_static_pad("src")
pipeline.set_state(Gst.State.PLAYING)
print 'potential caps:', srcpad.query_caps()
sink = Gst.ElementFactory.make("fakesink", "sink")
pipeline.add(sink)
filtercaps = Gst.caps_from_string("audio/x-raw, channels=(int)28, channel-positions=(int)< 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 >")
print "filter caps:", filtercaps
src.link_filtered(sink, filtercaps)
pipeline.set_state(Gst.State.PLAYING)
print 'actual caps:', srcpad.get_current_caps()
Gst.debug_bin_to_dot_file_with_ts(pipeline, Gst.DebugGraphDetails.ALL, 'caps')
文本形式和图表的输出都非常相似:
potential caps: audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)48000, channels=(int)[ 1, 28 ]
filter caps: audio/x-raw, channels=(int)28, channel-positions=(int)< 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 >
actual caps: audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)48000, channels=(int)2