2

When we use pictures in Python codes we can be helped by PIL to get RGB values which we can access as a list. I want to do something like that (getting numeric values from given signal) by using GStreamer in Python. I looked in the guide right here but he says nothing about saving the signal in the pipeline or getting numeric values from it.

Is Gstreamer able to do it? If so: Can anybody supply me with a short tutorial for getting numerical values from Gstreamer?

Danis Fischer
  • 375
  • 1
  • 7
  • 27

1 Answers1

1

Here is come code nicked from another SO answer which plays streaming audio given some URL using python

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

this will get you started ... then its a matter of finding what API call gives you access to the streaming audio buffer

.... audioread looks hopeful

from its docs

with audioread.audio_open(filename) as f:
    print(f.channels, f.samplerate, f.duration)
    for buf in f:
        do_something(buf)
Community
  • 1
  • 1
Scott Stensland
  • 26,870
  • 12
  • 93
  • 104