A
A
Anton2020-11-09 20:50:39
Sound processing
Anton, 2020-11-09 20:50:39

How to change the bitrate of an audio stream in real time?

Is it possible to change the bitrate of an audio stream using your backend server on the fly?
There are many Internet radio stations (The stations are not mine, just taken from the Internet).
Let's take for example a url stream in a 320kbps broadcast. Is it possible to stream it "on the fly" through your server at a lower bitrate? It is not possible to make alternative streams with different bitrates for all radio stations in advance, the stream is needed on demand, that is, the server will not simultaneously digest 700 radio stations into different bitrates. Let's say the user applied and then the process has already started.

The simplest example:

1) We know the url-stream ( https://mysite.com/stream.mp3 ) and we know in what bitrate it is given (320kbps).
2) We send this link to our server (no matter how), let's say using a POST request.
3) We receive a response in the form of the same audio data, but with a lower bitrate, previously specified in the same POST request. Let's say 128kbps.

I don't know how else to phrase this question. It is necessary to understand whether it is possible to implement this, what libraries will be required, in which language it will be easier to write an implementation, or is there something ready?
PS: Please do not offer any icecast and its "mounts" of streams to rebroadcast later, etc. Since the server does not know what kind of stream needs to be converted and will only know when it will be accessed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2020-11-13
@TequilaOne

In general, I did it without any theories. On php, using ffmpeg and "dynamic" creation of a mount in icecast via exec() and some php logic with updating metadata, since ffmpeg does not want and is not friendly with throwing meta information into the stream.
Subsequently, I had to add the implementation of passing metadata to icecast mounts, and deleting the created mounts via php + curl, pulling the link to destruction.
ps: If someone has used ffmpeg and icecast2 together, please tell us about the CPU load of each running ffmpeg instance. For me, this value ranges from 1.4 to 3.5% on a single 2600Mhz core.

I
Ivan Shumov, 2020-11-13
@inoise

The theory is here: https://en.wikipedia.org/wiki/Adaptive_bitrate_str... , and the rest follow the links

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question