【问题标题】:Decompose Audio stream from Gstreamer in Python 2.7在 Python 2.7 中从 Gstreamer 分解音频流
【发布时间】:2015-05-05 10:29:47
【问题描述】:

当我们在 Python 代码中使用图片时,PIL 可以帮助我们获取可以作为列表访问的 RGB 值。我想通过在 Python 中使用 GStreamer 来做类似的事情(从给定的信号中获取数值)。我在指南中查看了here,但他没有提及将信号保存在管道中或从中获取数值。

Gstreamer 能做到吗?如果是这样:任何人都可以为我提供从 Gstreamer 获取数值的简短教程吗?

【问题讨论】:

    标签: python python-2.7 signals signal-processing gstreamer


    【解决方案1】:

    这是从另一个 SO 答案中截取的代码,该答案使用 python 播放给定 URL 的流式音频

    import pygst
    import gst
    
    def on_tag(bus, msg):
        taglist = msg.parse_tag()
        print 'on_tag:'
        for key in taglist.keys():
            print '\t%s = %s' % (key, taglist[key])
    
    #our stream to play
    music_stream_uri = 'http://mp3channels.webradio.antenne.de/chillout'
    
    #creates a playbin (plays media form an uri) 
    player = gst.element_factory_make("playbin", "player")
    
    #set the uri
    player.set_property('uri', music_stream_uri)
    
    #start playing
    player.set_state(gst.STATE_PLAYING)
    
    #listen for tags on the message bus; tag event might be called more than once
    bus = player.get_bus()
    bus.enable_sync_message_emission()
    bus.add_signal_watch()
    bus.connect('message::tag', on_tag)
    
    #wait and let the music play
    raw_input('Press enter to stop playing...')
    

    here is the SO answer where this was nicked from

    这会让你开始......然后它的问题是找到什么 API 调用可以让你访问流音频缓冲区

    ....audioread 看起来很有希望

    来自其文档

    with audioread.audio_open(filename) as f:
        print(f.channels, f.samplerate, f.duration)
        for buf in f:
            do_something(buf)
    

    【讨论】:

    • 谢谢。我的问题是创建和访问读写缓冲区。我想知道该怎么做?理论上必须存在创建缓冲区的选项,但我找不到任何从给定源捕获缓冲区的示例。
    • 股票例子可以指点一下:/usr/share/gst-python/0.10/examples
    • 关于audioread:如何处理从gstreamer到它的变量?
    • audioread 似乎不支持从 HTTP 流(或任何其他非磁盘文件的数据)中读取数据
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-25
    • 2015-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多