我想捕獲原始緩衝區數據到音頻文件。就像這樣:捕獲音頻文件ExtAudioFileWrite
dstFormat.mSampleRate = 224000;
dstFormat.mFormatID = kAudioFormatMPEG4AAC;
dstFormat.mChannelsPerFrame = 1;
dstFormat.mBitsPerChannel = 16;
dstFormat.mBytesPerPacket = dstFormat.mBytesPerFrame = 2 * dstFormat.mChannelsPerFrame;
dstFormat.mFramesPerPacket = 1;
dstFormat.mFormatFlags = kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsSignedInteger;
OSStatus result = ExtAudioFileCreateWithURL((CFURLRef) inURL,
kAudioFileM4AType,
&dstFormat,
0,
kAudioFileFlags_EraseFile,
&audioFileRef)
我勾搭成一個功能具有下列參數: AudioUnit inUnit, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList * ioData
它裏面我想將數據寫入到文件中,但出現錯誤的參數-50錯誤。 result = ExtAudioFileWrite(audioFileRef,inNumberFrames,ioData);
如果我換成我自己ioData參數:
AudioBufferList *bufferList = (AudioBufferList*) malloc(sizeof(AudioBufferList));
bufferList->mNumberBuffers = 1;// ioData->mNumberBuffers;
for(UInt32 i=0;i<bufferList->mNumberBuffers;i++)
{
bufferList->mBuffers[i].mNumberChannels = 1;
bufferList->mBuffers[i].mDataByteSize = ioData->mBuffers[i].mDataByteSize; //ioData->mBuffers[i].mDataByteSize; // (1024*2) * dstFormat.mBytesPerFrame;
bufferList->mBuffers[i].mData = ioData->mBuffers[i].mData;
}
..我避開260MB文件第一第二。這裏有什麼問題?
謝謝你,我已經修復了這個問題,但你給了我一個很好的答案 – 2012-04-13 13:41:25
很高興聽到你有它的工作。究竟是什麼問題?你應該發佈工作代碼。 :) – 2012-04-13 14:24:35
http://stackoverflow.com/questions/3815231/recording-mono-on-iphone-in-ima4-format這篇文章幫了我很多 – 2012-04-14 13:04:32