2
votes

My question is partially answered by this: Which audio format can be recorded and played back by iPhone and Android?

However, I'd like to ask further, if possible.

The simplified use-case is this: a client app (which will be either iPhone or Android) will record audio via the built-in mic. This audio will then be sent to a server. From the same client app, the user can see a list of recorded audio files and streamed back for playback.

I'm trying to see what would be the best audio format for the recording and streamed playback.

I have two questions:

1) From the link I gave above, it seems that both iPhone and Android support AAC for recording. However, I'm confused about the variants of AAC. Android seems to support AAC ADTS, whereas the iPhone something different (MPEG-4). Are these the same?

2) I was hoping to be able to record in the same format on both iPhone/Android so that they can be streamed as-is to the client devices. However, if transcoding on the server is a better option, what would be the preferred format for that?

Thank you in advance!

1
Were you able to resolve this issue? I am facing a similar issue. Kindly help if possible. - ambit
I just put what I went with as my answer. Hope that works for you. - kurisukun

1 Answers

3
votes

In the end, on iOS, I ended up using

NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:

                                [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,                                    
                                [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
                                [NSNumber numberWithInt:16], AVEncoderBitRateKey,
                                [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                                [NSNumber numberWithFloat:16000.0], AVSampleRateKey,
                                nil];

and on Android:

_mediaRecorder = new MediaRecorder();
_mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
_mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
_mediaRecorder.setOutputFile(_mediaFile.getAbsolutePath());
_mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

And the resulting files were AAC files were playable on both iOS and Android. Hope that helps!