i'm trying to convert pcm audio got from AVAudioCapture to aac format. i use AudioConverterNew.But i always got an OSStatus 1718449215, i know it means kAudioFormatUnsupportedDataFormatError, but i don't know why, here's my code
OSStatus status;
AudioStreamBasicDescription sourceASBD = *sourceFormat;
AudioStreamBasicDescription destASBD = {0};
destASBD.mSampleRate = sourceASBD.mSampleRate;
destASBD.mFormatID = kAudioFormatMPEG4AAC;
destASBD.mChannelsPerFrame = 1;
UInt32 size = sizeof(destASBD);
status = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &size, &destASBD);
if (status != noErr) {
NSLog(@"AudoFormatGetProperty kAudioFormatProperty_FormatInfo error:%d", status);
}
AudioClassDescription *description = [self
getAudioClassDescriptionWithType:destASBD.mFormatID
fromManufacturer:kAppleSoftwareAudioCodecManufacturer];
if (!description) {
NSLog(@"get audio class Descriptin error");
return false;
}
AudioConverterReset(_converter);
status = AudioConverterNewSpecific(&sourceASBD, &destASBD, 1, description, &_converter);
if (status != noErr) {
NSLog(@"create audo converter error:%d", status);
return false;
}
i got the sourceFormat from CMSampleBufferRef, anyone know what's the problem? the sourceASDB is
mSampleRate = 44100
mFormatID = 1819304813 linearpcm
mFormatFlags = 12
mBytesPerPacket = 2
mFramesPerPacket = 1
mBytesPerFrame = 2
mChannelsPerFrame = 1
mBitsPerChannel = 16
mReserved = 0