使用AVCaptureAudioDataOutput时,CMSampleBuffer中存储的数据是什么?它通过委托(delegate)方法 –captureOutput:didOutputSampleBuffer:fromConnection:
传递 CMSampleBuffers 但是 CMSampleBuffer 里面有什么? PCM 还是压缩?采样率、 channel 数等是多少?这如何用于从设备流式传输音频?
谷歌搜索几个小时对我没有帮助。
提前致谢
最佳答案
看起来您可以通过这种方式获得 ASBD:
sampleBuffer->
CMSampleBufferGetFormatDescription ->
CMAudioFormatDescriptionGetStreamBasicDescription
然后 ASBD 将详细说明帧大小、是否压缩、字节顺序等。
为了证明这一点(没有错误检查)并获得采样率:
CMSampleBufferRef cmSampleBuffer = ...;
CMFormatDescriptionRef formatDescription =
CMSampleBufferGetFormatDescription(cmSampleBuffer);
const AudioStreamBasicDescription* const asbd =
CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription);
double sampleRate = asbd->mSampleRate;
关于ios - 音频 CMSampleBuffer 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8049999/