Audio format for iOS and Android

前端 未结 7 1478
故里飘歌
故里飘歌 2020-11-30 21:45

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 be

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 22:12

    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);
    

提交回复
热议问题