简体   繁体   English

AVAudioRecorder支持哪些格式录制声音?

[英]what are the formats supported in AVAudioRecorder for recording sound?

I have found a list of the different values (Audio Data Format) at http://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html#//apple_ref/doc/uid/TP40004488 我在http://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html#//apple_ref/doc/找到了不同值的列表(音频数据格式) UID / TP40004488

Audio Data Format Identifiers Identifiers for audio data formats, used in the AudioStreamBasicDescription structure. 音频数据格式标识符音频数据格式的标识符,用于AudioStreamBasicDescription结构。

kAudioFormatLinearPCM = 'lpcm', kAudioFormatLinearPCM ='lpcm',

kAudioFormatAC3 = 'ac-3', kAudioFormatAC3 ='ac-3',

kAudioFormat60958AC3 = 'cac3', kAudioFormat60958AC3 ='cac3',

kAudioFormatAppleIMA4 = 'ima4', kAudioFormatAppleIMA4 ='ima4',

kAudioFormatMPEG4AAC = 'aac ', kAudioFormatMPEG4AAC ='aac',

kAudioFormatMPEG4CELP = 'celp', kAudioFormatMPEG4CELP ='celp',

kAudioFormatMPEG4HVXC = 'hvxc', kAudioFormatMPEG4HVXC ='hvxc',

kAudioFormatMPEG4TwinVQ = 'twvq', kAudioFormatMPEG4TwinVQ ='twvq',

kAudioFormatMACE3 = 'MAC3', kAudioFormatMACE3 ='MAC3',

kAudioFormatMACE6 = 'MAC6', kAudioFormatMACE6 ='MAC6',

kAudioFormatULaw = 'ulaw', kAudioFormatULaw ='ulaw',

kAudioFormatALaw = 'alaw', kAudioFormatALaw ='alaw',

kAudioFormatQDesign = 'QDMC', kAudioFormatQDesign ='QDMC',

kAudioFormatQDesign2 = 'QDM2', kAudioFormatQDesign2 ='QDM2',

kAudioFormatQUALCOMM = 'Qclp', kAudioFormatQUALCOMM ='Qclp',

kAudioFormatMPEGLayer1 = '.mp1', kAudioFormatMPEGLayer1 ='。mp1',

kAudioFormatMPEGLayer2 = '.mp2', kAudioFormatMPEGLayer2 ='。mp2',

kAudioFormatMPEGLayer3 = '.mp3', kAudioFormatMPEGLayer3 ='。mp3',

kAudioFormatTimeCode = 'time', kAudioFormatTimeCode ='时间',

kAudioFormatMIDIStream = 'midi', kAudioFormatMIDIStream ='midi',

kAudioFormatParameterValueStream = 'apvs', kAudioFormatParameterValueStream ='apvs',

kAudioFormatAppleLossless = 'alac' kAudioFormatAppleLossless ='alac'

kAudioFormatMPEG4AAC_HE = 'aach', kAudioFormatMPEG4AAC_HE ='aach',

kAudioFormatMPEG4AAC_LD = 'aacl', kAudioFormatMPEG4AAC_LD ='aacl',

kAudioFormatMPEG4AAC_ELD = 'aace', kAudioFormatMPEG4AAC_ELD ='aace',

kAudioFormatMPEG4AAC_HE_V2 = 'aacp', kAudioFormatMPEG4AAC_HE_V2 ='aacp',

kAudioFormatMPEG4AAC_Spatial = 'aacs', kAudioFormatMPEG4AAC_Spatial ='aacs',

kAudioFormatAMR = 'samr', kAudioFormatAMR ='samr',

kAudioFormatAudible = 'AUDB', kAudioFormatAudible ='AUDB',

kAudioFormatiLBC = 'ilbc', kAudioFormatiLBC ='ilbc',

kAudioFormatDVIIntelIMA = 0x6D730011, kAudioFormatDVIIntelIMA = 0x6D730011,

kAudioFormatMicrosoftGSM = 0x6D730031, kAudioFormatMicrosoftGSM = 0x6D730031,

kAudioFormatAES3 = 'aes3' kAudioFormatAES3 ='aes3'

However, I dont think we can use all the formats mentioned (eg mp3). 但是,我不认为我们可以使用所有提到的格式(例如mp3)。

Can anyone help me out with the formats that are supported for recording sound using AVAudioRecorder ? 任何人都可以帮助我使用AVAudioRecorder录制声音支持的格式吗?

Thanks. 谢谢。

As per apple docs Apple Core Audio Format Specification 1.0 it should now support mp3 although I haven't tested it, this is the current enumeration they support: 根据Apple docs Apple Core Audio Format Specification 1.0,它现在应该支持mp3,虽然我还没有测试过,这是他们支持的当前枚举:

enum {
    kAudioFormatLinearPCM      = 'lpcm',
    kAudioFormatAppleIMA4      = 'ima4',
    kAudioFormatMPEG4AAC       = 'aac ',
    kAudioFormatMACE3          = 'MAC3',
    kAudioFormatMACE6          = 'MAC6',
    kAudioFormatULaw           = 'ulaw',
    kAudioFormatALaw           = 'alaw',
    kAudioFormatMPEGLayer1     = '.mp1',
    kAudioFormatMPEGLayer2     = '.mp2',
    kAudioFormatMPEGLayer3     = '.mp3',
    kAudioFormatAppleLossless  = 'alac'
};

List above just 列出上面的内容

currently defined values for the mFormatID field 当前为mFormatID字段定义的值

not supported for recording. 不支持录制。

There are tested with AVAudioRecorder formats (with sample rates): 有AVAudioRecorder格式测试(带采样率):

"MPEG4AAC (8000, 11025, 22050, 32000, 44100, 48000)",
"AppleLossless (8000, 11025, 22050, 32000, 44100, 48000)",
"MPEG4AAC_HE (32000, 44100, 48000)",
"MPEG4AAC_LD (22050, 32000, 44100, 48000)",
"MPEG4AAC_ELD (22050, 32000, 44100, 48000)",
"MPEG4AAC_ELD_SBR (22050, 32000, 44100, 48000)",
"MPEG4AAC_ELD_V2 (22050, 32000, 44100, 48000)"

Example: 例:

[[AVAudioRecorder alloc] initWithURL:outputFileURL
                            settings:@{
                                       AVFormatIDKey : @(kAudioFormatMPEG4AAC),
                                       AVSampleRateKey : @(44100.0),
                                       AVNumberOfChannelsKey : @(2)
                                       }
                               error:&error];

also Supported Audio file formats 支持音频文件格式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM