0

I got the recorded AudioQueueBufferRef buffer using the following code.

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

And then, I send the data to my server. However, FFMPEG isn't able to read that because the data is not in any audio standard format.

It's just plain data.

So, how do I do either on iPhone or backend ffmpeg to convert that raw buffer to WAV?

Thank so much.

moeseth
  • 1,855
  • 5
  • 23
  • 47

1 Answers1

0

You could write the WAV headers yourself. However, in a similar situation I chose to use the sox command line tool. This is better for server side. You can take your raw audio data, save it to a file, and then execute the following command.

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>

Your raw audio file must have a .raw file extension.

William Rosenbloom
  • 2,506
  • 1
  • 14
  • 37