0

I am trying to record audio as flac codec instead of opus codec. How can I do that? I have tried setting codec to flac:

let blob = new Blob(audioChunks,{type: 'audio/ogg; codecs=flac' });

I also tried this:

var options = {
    audioBitsPerSecond : 32000,
   mimeType: 'audio/ogg; codecs=flac' 
}
var mediaRecorder = new MediaRecorder(audioStream,options);

But when audio is recorded and saved, I check properties it say codec is opus.

1 Answer 1

1

You can check, if a codec is supported using:

MediaRecorder.isTypeSupported('audio/ogg;codecs=opus')

As far as I know FLAC isn't supported by current browsers. You can convert the recording on client side using Flac.js or you simply convert it on the backend.

Sign up to request clarification or add additional context in comments.

2 Comments

Just a note that browsers sometimes claims they support particular codec, but in reality that may not be true. You can see live test: sitelint.com/lab/media-recoder-supported-mime-type
WEBM container + OPUS codec can be a good option in many cases: MediaRecorder.isTypeSupported('audio/webm;codecs=opus')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.