iphoneobjective-ciosxcode

How to change Audio CMSampleBuffer format(change the mSampleRate 44100.000000 to 8000.000000.)


I am using AVCaptureAudioDataOutput for audio output and getting result form

          - (void)captureOutput:(AVCaptureOutput *)captureOutputdidOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
   fromConnection:(AVCaptureConnection *)connection

but i want to change the sampleBuffer audio format (CMSampleBufferGetFormatDescription). please help me if it is possible.want to change mSampleRate .

Currently getting
mediaSpecific: {ASBD: {mSampleRate: 44100.000000mFormatID: 'lpcm'mFormatFlags: 0xcmBytesPerPacket: 2mFramesPerPacket: 1mBytesPerFrame: 2mChannelsPerFrame: 1mBitsPerChannel: 16 }

but i need to change the mSampleRate 44100.000000 to 8000.000000.


Solution

  • Take a look here: https://developer.apple.com/documentation/avfaudio/avaudiorecorder/init(url:settings:)#Discussion

    You have to setup the AVAudioRecorder.

    Hope, that helps!