AVFormatIDKey 音频的格式
取值详表
enum
{
kAudioFormatLinearPCM ='lpcm',
kAudioFormatAC3 ='ac-3',
kAudioFormat60958AC3 ='cac3',
kAudioFormatAppleIMA4 ='ima4',
kAudioFormatMPEG4AAC ='aac ',
kAudioFormatMPEG4CELP ='celp',
kAudioFormatMPEG4HVXC ='hvxc',
kAudioFormatMPEG4TwinVQ ='twvq',
kAudioFormatMACE3 ='MAC3',
kAudioFormatMACE6 ='MAC6',
kAudioFormatULaw ='ulaw',
kAudioFormatALaw ='alaw',
kAudioFormatQDesign ='QDMC',
kAudioFormatQDesign2 ='QDM2',
kAudioFormatQUALCOMM ='Qclp',
kAudioFormatMPEGLayer1 ='.mp1',
kAudioFormatMPEGLayer2 ='.mp2',
kAudioFormatMPEGLayer3 ='.mp3',
kAudioFormatTimeCode ='time',
kAudioFormatMIDIStream ='midi',
kAudioFormatParameterValueStream ='apvs',
kAudioFormatAppleLossless ='alac',
kAudioFormatMPEG4AAC_HE ='aach',
kAudioFormatMPEG4AAC_LD ='aacl',
kAudioFormatMPEG4AAC_ELD ='aace',
kAudioFormatMPEG4AAC_ELD_SBR ='aacf',
kAudioFormatMPEG4AAC_ELD_V2 ='aacg',
kAudioFormatMPEG4AAC_HE_V2 ='aacp',
kAudioFormatMPEG4AAC_Spatial ='aacs',
kAudioFormatAMR ='samr',
kAudioFormatAudible ='AUDB',
kAudioFormatiLBC ='ilbc',
kAudioFormatDVIIntelIMA =0x6D730011,
kAudioFormatMicrosoftGSM =0x6D730031,
kAudioFormatAES3 ='aes3'
};
AVSampleRateKey 录音频率
[settings setValue:[NSNumbernumberWithFloat:44100.0f]forKey:AVSampleRateKey];
AVNumberOfChannelsKey 音频通道数量
[settings setValue:[NSNumbernumberWithInteger:1]forKey:AVNumberOfChannelsKey];
AVEncoderAudioQualityKey 音频的质量
enum {//质量从低到高
AVAudioQualityMin = 0,
AVAudioQualityLow = 0x20,
AVAudioQualityMedium = 0x40,
AVAudioQualityHigh = 0x60,
AVAudioQualityMax = 0x7F
};
[settings setValue:[NSNumbernumberWithInteger:AVAudioQualityLow]forKey:AVEncoderAudioQualityKey];
示例代码:
//设置录音选项,如文件类型,频率,通道,质量等
-(NSDictionary *) audioRecordingSettings
{
NSDictionary * ret ;
NSMutableDictionary * settings = [[NSMutableDictionaryalloc]init];
//kAudioFormatAppleLossless 其中k是小写
[settings setValue:[NSNumbernumberWithInteger:kAudioFormatAppleLossless]forKey:AVFormatIDKey];
[settings setValue:[NSNumbernumberWithFloat:44100.0f]forKey:AVSampleRateKey];
[settings setValue:[NSNumbernumberWithInteger:1]forKey:AVNumberOfChannelsKey];
[settings setValue:[NSNumbernumberWithInteger:AVAudioQualityLow]forKey:AVEncoderAudioQualityKey];
ret = [NSDictionarydictionaryWithDictionary:settings];
return ret;
}