Reputation: 1364
The mimeType of the MediaRecorder changes after I start recording. I have a JSFiddle which reproduces the behavior here:
https://jsfiddle.net/mattdeeds/5fvh3ac6/18/
I set the options to specify the pcm codec:
let options = {
mimeType: "audio/webm;codec=pcm",
};
say('message0', MediaRecorder.isTypeSupported(options.mimeType));
As expected:
I create the MediaRecorder:
rec = new MediaRecorder(stream, options);
say('message1', rec.mimeType);
As expected:
Now, I press "start" and "stop" to record a sample which executes this code:
rec.ondataavailable = e => {
audioChunks.push(e.data);
if (rec.state == "inactive"){
say('message2', rec.mimeType);
say('message3', e.data.type);
And what I get is not expected:
I expected the MediaRecorder to use the codec I specified. Per the specification:
2.1.5 (constructor) Let recorder have a [[ConstrainedMimeType]] internal slot, initialized to the value of options’ mimeType member.
2.3.8 (start) If the [[ConstrainedMimeType]] slot specifies a media type, container, or codec, then constrain the configuration of recorder to the media type, container, and codec specified in the [[ConstrainedMimeType]] slot.
To me this pretty clearly states that if I request PCM which is supported, it will record in PCM. Is this a Chrome bug?
Upvotes: 0
Views: 2683
Reputation: 1364
codec
is not a valid Mime Type parameter. You need to use codecs
if you want it to be respected.
let options = {
mimeType: "audio/webm;codecs=pcm",
};
With this change, your Fiddle works as expectd:
Upvotes: 1