AVAudioRecorder文件太大了

sum*_*HAY 1 iphone cocoa-touch objective-c avaudiorecorder ios

我正在使用AVAudioRecorder录制音频,文件太大.像20秒,出来是1.2mb?我怎样才能让它变小?谢谢.

小智 7

这是我发现的最佳方式,您也可以使用它:

NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithCapacity:0];

[settings setValue :[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];//??
[settings setValue:[NSNumber numberWithFloat:8000.0] forKey:AVSampleRateKey]; //??8000?
[settings setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];//??
[settings setValue :[NSNumber numberWithInt:8] forKey:AVLinearPCMBitDepthKey];//???
[settings setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[settings setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
//Encoder
[settings setValue :[NSNumber numberWithInt:12000] forKey:AVEncoderBitRateKey];//???
[settings setValue :[NSNumber numberWithInt:8] forKey:AVEncoderBitDepthHintKey];//???
[settings setValue :[NSNumber numberWithInt:8] forKey:AVEncoderBitRatePerChannelKey];//?????
[settings setValue :AVAudioQualityMin           forKey:AVEncoderAudioQualityKey];//????
Run Code Online (Sandbox Code Playgroud)