Page 1 of 1

Detect HTTP Stream Content Type and change encoder

Posted: Fri Jun 17, 2022 9:57 pm
by shaheenm
Hi I am working on an audio streaming device that provides streams in two formats opus and mp3. when connecting to a stream i need to detect the audio format and load the correct decoder.

I have used the examples from the esp-adf to create the pipeline and confirm that I am able to stream either mp3 or opus separately. But i'm having trouble detecting the audio type before initialising the decoder and linking up the pipeline.

I have not been able to find any examples that have this type of functionality, to change the encoder to suit the stream audio format. All the examples assume a static decoder type.

Does anyone have an idea on how to setup the pipeline to be able to change the decoder on the fly if the stream audio format changes?

Re: Detect HTTP Stream Content Type and change encoder

Posted: Wed Jun 22, 2022 12:18 pm
by tempo.tian
Opus always encapsulated in OGG container.
It is easy to check file header to determine whether it is opus or mp3.
Ex: Opus starts with "oggS" and "OpusHead" while mp3 starts with "ID3" or 0xFF.

Re: Detect HTTP Stream Content Type and change encoder

Posted: Tue Jun 28, 2022 4:57 am
by ESP_Vikram
Maybe ADF could do this for you! Please refer: https://github.com/espressif/esp-adf/tr ... ct_decoder