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 and receive a raw PCM buffer. Specifically, I want to read chunks of the file incrementally rather than reading the whole file into memory.

Some specific questions: How can I accomplish this with Gstreamer? With pygst specifically? Is there a particular "sink" element I need to use to read data from the stream? Is there a preferred way to read data from a pygst Buffer object? How do I go about controlling the rate at which I consume data (rather than just entering a "main loop")?

8
задан adrian 17 August 2010 в 23:23
поделиться

1 ответ

Чтобы вернуть данные в ваше приложение, рекомендуется использовать appsink .

На основе простого аудиоплеера, такого как этот (и замените oggdemux / vorbisdec на decodebin & capsfilter на caps = "audio / x-raw-int"), измените autoaudiosink на appsink и подключитесь Сигнал "new-buffer" функции Python + установите для параметра "emit-messages" значение True. Функция будет получать декодированные фрагменты данных PCM / int. Скорость декодирования будет зависеть от скорости, с которой вы можете декодировать и использовать. Поскольку сигнал нового буфера находится в контексте потока Gstreamer, вы можете просто спать / ждать в этой функции, чтобы контролировать или замедлять скорость декодирования.

5
ответ дан 5 December 2019 в 23:12
поделиться
Другие вопросы по тегам:

Похожие вопросы: