Detect HTTP Stream Content Type and change encoder

shaheenm
Posts: 3
Joined: Mon Jan 16, 2017 12:52 pm

Detect HTTP Stream Content Type and change encoder

Postby shaheenm » Fri Jun 17, 2022 9:57 pm

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?

tempo.tian
Posts: 40
Joined: Wed Jun 22, 2022 12:10 pm

Re: Detect HTTP Stream Content Type and change encoder

Postby tempo.tian » Wed Jun 22, 2022 12:18 pm

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.

ESP_Vikram
Posts: 25
Joined: Fri Nov 23, 2018 12:07 pm

Re: Detect HTTP Stream Content Type and change encoder

Postby ESP_Vikram » Tue Jun 28, 2022 4:57 am

Maybe ADF could do this for you! Please refer: https://github.com/espressif/esp-adf/tr ... ct_decoder

Who is online

Users browsing this forum: No registered users and 12 guests