Answer the question
In order to leave comments, you need to log in
How to make mp3 from audioBuffer?
Good day, I'm sorry, but this topic has been confusing me for the second day already, IMHO has never touched the web audio api and has already stopped sleeping. Maybe there are people here who can help solve the problem.
In general, the essence is as follows:
I am writing an application in react. all OK. until the moment when it became necessary for me to upload audio files. they come from different places and in different formats. It can be wave, wav. mp3, acc and so on, in general, everything that has a mime type - audio/*. There are no problems with loading. input file, form data and everything is ok. BUT!!!!!!!
In order not to waste traffic and not load the server with unnecessary data, you need to compress (convert/transcode) the file into mp3 format on the client side and compress it to a certain size.
An example that I like (admins are not advertising, but an example): here.
Having started to understand this topic, I calmly get a file buffer:
const reader = new FileReader();
reader.readAsArrayBuffer(input.files[0]);
reader.addEventListener('load', ({ target }) => {
if (!target.result) {
return;
}
this.audioCtx.decodeAudioData(buffer)
.then(audioBuffer => {
// собсна audioBuffer это и есть нужный буффер
});
}, false);
ffmpeg -i sound.mp3 -ar 32000 -ac 2 -b:a 64K -f mp3 result.mp3
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question