Search code examples
javascriptiosmobile-safarihtml5-audioaudio-recording

poor audio quality of recordings in iOS safari browser


I'm trying to understand the limitations of safari ios (12.3.1) for recording audio in the browser. This is because any speech I record - regardless of the codec / container - is much lower quality than equivalent audio recorded via a native ios app.

Opus, wav and mp3 files recorded within safari ios (iphone8) seem capped at a certain quality, regardless of the encoder settings (eg bitrate / complexity / samplerate / channels). But when recording speech within a native app, I find I can generate consistently excellent results.

The audio quality within safari is unaffected by: recording audio using different javascript recorders (wav only) and javascript encoders (opus and mp3); clearing the browser cache; reloading js from a private browser window; switching on MediaRecorder API experimental feature. But


Solution

  • I've spent the last few days playing with getUserMedia() on various devices. After analyzing the WAV files produced (waveform & spectrum analysis), here are the few infos I've been able to get from them.

    Safari iOS will produce a decent WAV file (default is 48000Khz, 16 bit, Stereo), but no matter the constraints passed to getUserMedia() the audio spectrum will not contain any frequency higher than 14Khz. So the WAV container is OK, but the quality of the audio written to it is about the same as the "medium" audio preset that can be found in native iOS applications.

    iOS wave file spectrum

    The consequence of this is a very pronounced "telephone" effect on the audio, and a file that is unusable for professional audio purposes.

    Android devices produce a similar result in the default configuration (strong limitation of the audio spectrum), but by passing a set of constraints that disable the assistances like these :

    autoGainControl:false, 
    echoCancellation:false, 
    noiseSuppression:false
    

    we can achieve a very acceptable audio quality.

    android 8 wave file spectrum

    Unfortunately, these same settings do not allow iOS to achieve acceptable audio quality and as of now there seems to be no workaround available.