I’m using the Audio SDK and am surprised that the file sizes for the recorded audio seem unchanged regardless of RECORDING_OPTIONS_PRESET_HIGH_QUALITY or RECORDING_OPTIONS_PRESET_LOW_QUALITY is used. For point of reference, a 3 second audio clip comes out to about 650kb in both cases.
For iOS, the only difference between the presets is that audioQuality value is changed (from min to max). If the audio quality is changing, it doesn’t appear to influence the size of the file in a meaningful way.
This may all be as expected. What I’m actually trying to do is just figure out what settings I need to use to ensure that my audio files aren’t enormous. I suspected the extension of .caf isn’t helping things. With some digging, I found settings that work for .m4a…
This makes a 3 second file 100kb. A big improvement from baseline, but the file size is still way larger than I’d like.
The docs note that these settings are fickle and there’s a future desire to document which combo of settings works. I’m wondering if there’s an in-progress collection that I can reference? Or perhaps someone has figure out how to record in an extension with much smaller file sizes?
Update: I’ve kept experimenting and now have a set of recording options that cuts the file size by another third. (A 3 second file is ~ 35kb)…
ios: {
extension: '.caf',
audioQuality: Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX, // Doesn't impact size
sampleRate: 8000, // Doesn't have an impact dropping lower than 8000
numberOfChannels: 1,
bitRate: 128000, // Lowering doesn't have an impact
linearPCMBitDepth: 8, // Doesn't have an impact dropping any lower than 8
linearPCMIsBigEndian: false,
linearPCMIsFloat: false,
},
I’m back to the .caf format. I’m wondering if there’s a “floor” to the sample rate and bit depth for caf? I’m just grasping around in the dark here so if anyone actually understands this stuff, I’d love your input.
For future travelers, here are the recording options that balance quality and file size that I landed on through a TON of trial and error:
android: {
extension: '.mp4',
outputFormat: Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4,
audioEncoder: Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_HE_AAC,
sampleRate: 22050, // No impact on file size or quality
numberOfChannels: 1,
bitRate: 32000, // MODIFY THIS FOR QUALITY AND SIZE
},
ios: {
extension: '.mp4',
outputFormat: Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC,
audioQuality: Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX, // Doesn't impact size
sampleRate: 22050, // Doesn't have an impact dropping lower than 8000. MODIFY THIS FOR QUALITY AND SIZE
numberOfChannels: 1,
bitRate: 0, // I think this has to be 0 because mp4 is lossy audio
linearPCMBitDepth: 16, // Doesn't have an impact dropping any lower than 8
linearPCMIsBigEndian: false,
linearPCMIsFloat: false,
},
Hey @nsdub, thanks a ton for continuing to update the community with your findings! Always love to see when people take time out of their day to help out fellow Expo users. Let me find out if we have any doc or resource in the works on this internally. We’ll follow up here and let you know.