what are the formats supported in AVAudioRecorder for recording sound?

前端 未结 2 1253
生来不讨喜
生来不讨喜 2020-12-24 10:13

I have found a list of the different values (Audio Data Format) at http://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference

相关标签:
2条回答
  • 2020-12-24 10:24

    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:

    enum {
        kAudioFormatLinearPCM      = 'lpcm',
        kAudioFormatAppleIMA4      = 'ima4',
        kAudioFormatMPEG4AAC       = 'aac ',
        kAudioFormatMACE3          = 'MAC3',
        kAudioFormatMACE6          = 'MAC6',
        kAudioFormatULaw           = 'ulaw',
        kAudioFormatALaw           = 'alaw',
        kAudioFormatMPEGLayer1     = '.mp1',
        kAudioFormatMPEGLayer2     = '.mp2',
        kAudioFormatMPEGLayer3     = '.mp3',
        kAudioFormatAppleLossless  = 'alac'
    };
    
    0 讨论(0)
  • 2020-12-24 10:25

    List above just

    currently defined values for the mFormatID field

    not supported for recording.

    There are tested with AVAudioRecorder formats (with sample rates):

    "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

    0 讨论(0)
提交回复
热议问题