AudioQueue字节到ffmpeg可理解的WAV格式

时间:2015-12-24 06:09:08

标签: ios ffmpeg wav audiotoolbox audioqueueservices

我使用以下代码获取了录制的 AudioQueueBufferRef 缓冲区。

NSData *data = [NSData dataWithBytes:inBuffer->mAudioData length:inBuffer->mAudioDataByteSize];

然后,我将数据发送到我的服务器。但是,FFMPEG无法读取,因为数据不是任何音频标准格式。

这只是简单的数据。

那么,如何在iPhone或后端ffmpeg上将原始缓冲区转换为WAV?

非常感谢。

1 个答案:

答案 0 :(得分:0)

您可以自己编写WAV标题。但是,在类似的情况下,我选择使用sox命令行工具。这对服务器端更好。您可以获取原始音频数据,将其保存到文件中,然后执行以下命令。

sox -r <your sample rate> -b <bytes per frame> -c <number of channels> -e <your sample encoding> <your raw audio file> <your-output-file.wav>

您的原始音频文件必须具有.raw文件扩展名。