0

我正在尝试将从 AVAudioCapture 获得的 pcm 音频转换为 aac 格式。我使用 AudioConverterNew。但我总是得到一个 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,有人知道问题出在哪里吗?源ASDB是

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

0 回答 0