AudioConverterNew返回OSStatus fmt

时间:2015-05-27 16:22:42

标签: ios audio-streaming audio-converter

我正在尝试将从AVAudioCapture获取的pcm音频转换为aac格式。我使用AudioConverterNew.But我总是得到一个OSStatus 1718449215,我知道这意味着kAudioFormatUnsupportedDataFormatError,但我不知道为什么,这是我的代码

 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;
}

我从CMSampleBufferRef获得了sourceFormat,有谁知道这是什么问题? sourceASDB​​是

    mSampleRate = 44100
    mFormatID = 1819304813 linearpcm
    mFormatFlags = 12
    mBytesPerPacket = 2
    mFramesPerPacket = 1
    mBytesPerFrame = 2
    mChannelsPerFrame = 1
    mBitsPerChannel = 16
    mReserved = 0

0 个答案:

没有答案