I'm trying to convert a blob audio file to .mp4 type which is generated from MediaRecorder it is returning with webm type and I have tried other types in MimeType(attribute in MediaRecorder to set the type) but they are not supported so I have tried ffmpeg npm library but it was asking for path of the file but i'm not saving it so that also didn't work for me. Any suggestion and answer that will help!!
This is how I'm recording it and it is working fine
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const mediaRecorder = new MediaRecorder(stream);
const audioChunks = [];
mediaRecorder.addEventListener("dataavailable", event => {
audioChunks.push(event.data);
});
const start = () => mediaRecorder.start();
const stop = () =>
new Promise(resolve => {
mediaRecorder.addEventListener("stop", async () => {
const audioBlob = new Blob(audioChunks,{
'type': 'audio/wav;'
});
const audiomp3 = URL.createObjectURL(audioBlob);
const audio = new Audio(audiomp3);
const play = () => audio.play();
resolve({ audioBlob,audio,play });
});
mediaRecorder.stop();
});