Audio format CMSampleBuffer

What is the data stored in CMSampleBuffer when using AVCaptureAudioDataOutput? It provides CMSampleBuffers through the delegation method –captureOutput:didOutputSampleBuffer:fromConnection: but what is inside the CMSampleBuffer? PCM or compressed? What are samplers, number of channels, etc.? How can this be used to stream audio from a device? Googling for several hours did not help me.

Thanks in advance

+6
source share
1 answer

it looks like you can get ASBD like this:

 sampleBuffer-> CMSampleBufferGetFormatDescription -> CMAudioFormatDescriptionGetStreamBasicDescription 

then ASBD will detail the frame sizes if it is compressed, endianness, etc.

To demonstrate this (without error checking) and get the sampling rate:

 CMSampleBufferRef cmSampleBuffer = ...; CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(cmSampleBuffer); const AudioStreamBasicDescription* const asbd = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription); double sampleRate = asbd->mSampleRate; 
+7
source

Source: https://habr.com/ru/post/901017/


All Articles