gpt4 book ai didi

ios - 音频 CMSampleBuffer 格式

转载 作者:可可西里 更新时间:2023-11-01 03:30:16 26 4
gpt4 key购买 nike

使用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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com