Closed dongzeli95 closed 4 months ago
@dongzeli95 did you try to check if the native mediarecorder can handle the sample rate restriction? You could check the capabilities first (doesn't work in Firefox though)
const audioTrack = this.mediaStream.getAudioTracks()[0]
if (typeof audioTrack.getCapabilities === 'function') {
console.log('capabilities audio', audioTrack.getCapabilities())
}
Yes, @bschelling is on the right track. Safari doesn't expose the sampleRate
of a MediaStreamTrack
. It needs a little help.
const { stream } = mediaStreamAudioDestinationNode;
Object.defineProperty(
stream.getAudioTracks()[0],
'getSettings',
{ value: () => ({ sampleRate: audioContext.sampleRate }) }
);
const mediaRecorder = new MediaRecorder(stream);
Hi team, I tried to set this sample rate to
16000
and it worked perfect on Chrome, but doesn't work on Safari. When I use my laptop speaker, the default sample rate is48000
, on safari this won't get changed even though I set the audio context. Any ideas?668 I suppose it's related to some inner workings of safari?