Skip to content Skip to sidebar Skip to footer

Use (python) Gstreamer To Decode Audio (to Pcm Data)

I'm writing an application that uses the Python Gstreamer bindings to play audio, but I'm now trying to also just decode audio -- that is, I'd like to read data using a decodebin a

Solution 1:

To get the data back in your application, the recommended way is appsink.

Based on a simple audio player like this one (and replace the oggdemux/vorbisdec by decodebin & capsfilter with caps = "audio/x-raw-int"), change autoaudiosink to appsink, and connect "new-buffer" signal to a python function + set "emit-signals" to True. The function will receive decoded chunks of PCM/int data. The rate of the decoding will depend on the rate at which you can decode and consume. Since the new-buffer signal is in the Gstreamer thread context, you could just sleep/wait in that function to control or slow down the decoding speed.

Post a Comment for "Use (python) Gstreamer To Decode Audio (to Pcm Data)"