Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
420 views
in Technique[技术] by (71.8m points)

Audio format for iOS and Android

Sorry if I am asking too generic question.

We are in the process of developing an application which records and plays audio on mobile devices. This application is being developed for both Android and iOS. The application will record audio using device mic and store it in the server.

User (on Android and iOS) can open the application and play the sound which is stored on the server. The sound format we are using is AAC. In iOS its working fine. We can record and play the AAC files.

But on Android (Samsung S3 and Samsung Galaxy Y) we cannot record sound in AAC format. But in S3 we can play the AAC file.

My question is, which format we should select for recording and playing in Android (should support from 2.3 to Jellybean) and iOS. Should we use MP4?

One solution we have is, on the backend side we can convert the audio file to AAC, MP4 or 3GP and give the supported files to mobiles based on the versions.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Android and iOS use the same server to storage records. All records are saved without any extension.

When Android downloads a record from the server, my app adds an ".aac" extension.
When using iOS, it adds an ".m4a" extension.

The same record plays good on both mobile platforms.

Record on iOS:

NSDictionary recorderSettings = [[NSDictionary alloc] initWithObjectsAndKeys:
? ? ? ? ? ? ? ? ? ? ? ? [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
? ? ? ? ? ? ? ? ? ? ? ? [NSNumber numberWithInt:16000],AVSampleRateKey,
? ? ? ? ? ? ? ? ? ? ? ? [NSNumber numberWithInt:1],AVNumberOfChannelsKey,
? ? ? ? ? ? ? ? ? ? ? ? [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
? ? ? ? ? ? ? ? ? ? ? ? [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
? ? ? ? ? ? ? ? ? ? ? ? [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
? ? ? ? ? ? ? ? ? ? ? ? nil];

For Android:

myRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
myRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
myRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
myRecorder.setAudioSamplingRate(16000);
myRecorder.setAudioChannels(1);
mRecorder.setOutputFile(fileName);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...