我有一个数据流,特别是来自一个MP3流。为了将其转换为AVAudioPCBBuffer,我创建了一个AVAudioFormat来对其进行如下描述:
AVAudioFormat* format = [[AVAudioFormat alloc] initWithStreamDescription:&description];当打印格式时,输出是:
<AVAudioFormat 0x2818944b0: 2 ch, 48000 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame>现在,当我试图像这样初始化AVAudioPCMBuffer时:
AVAudioPCMBuffer* pcbBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:frameCount];我有个例外:
required condition is false: isPCMFormat(fmt)我做错了什么?
谢谢
发布于 2021-12-06 21:32:54
您使用了错误的AVAudioBuffer子类。AVAudioPCMBuffer是用于未压缩的“脉冲编码调制”音频。你想要的是AVAudioCompressedBuffer。
https://stackoverflow.com/questions/70250222
复制相似问题