核心音频中 AAC 文件的数据包大小 (mBytesPerPacket) 或比特率
Packet size (mBytesPerPacket) or the bitrate for AAC files in Core Audio
我想配置 AudioStreamBasicDescription
具有 恒定比特率 AAC 类型。
AudioStreamBasicDescription clientFormat = {0};
clientFormat.mSampleRate = 44100.0;
clientFormat.mFormatID = kAudioFormatMPEG4AAC;
clientFormat.mFormatFlags = kMPEG4Object_AAC_Main;
clientFormat.mChannelsPerFrame = 2;
clientFormat.mBytesPerPacket = 0;
clientFormat.mBytesPerFrame = 0;
clientFormat.mFramesPerPacket = 1024;
clientFormat.mBitsPerChannel = 0;
clientFormat.mReserved = 0;
对于 mBytesPerPacket
Apple 文档说:
The number of bytes in a packet of audio data. To indicate variable
packet size, set this field to 0. For a format that uses variable
packet size, specify the size of each packet using an
AudioStreamPacketDescription structure.
我想把它作为一个常量,所以我必须在那里插入一个非零值(所需的大小),但除 0 之外的所有值都失败了。
有什么帮助吗?
事实证明,我们可以直接在 AudioConverter 上设置编解码器属性。
所以我做了:
AudioConverterSetProperty(acRef, kAudioCodecPropertyBitRateControlMode,
sizeof(control_mode), &control_mode);
AudioConverterSetProperty(acRef, kAudioCodecPropertyCurrentTargetBitRate,
sizeof(_bitRate), &_bitRate);
我想配置 AudioStreamBasicDescription
具有 恒定比特率 AAC 类型。
AudioStreamBasicDescription clientFormat = {0};
clientFormat.mSampleRate = 44100.0;
clientFormat.mFormatID = kAudioFormatMPEG4AAC;
clientFormat.mFormatFlags = kMPEG4Object_AAC_Main;
clientFormat.mChannelsPerFrame = 2;
clientFormat.mBytesPerPacket = 0;
clientFormat.mBytesPerFrame = 0;
clientFormat.mFramesPerPacket = 1024;
clientFormat.mBitsPerChannel = 0;
clientFormat.mReserved = 0;
对于 mBytesPerPacket
Apple 文档说:
The number of bytes in a packet of audio data. To indicate variable packet size, set this field to 0. For a format that uses variable packet size, specify the size of each packet using an AudioStreamPacketDescription structure.
我想把它作为一个常量,所以我必须在那里插入一个非零值(所需的大小),但除 0 之外的所有值都失败了。
有什么帮助吗?
事实证明,我们可以直接在 AudioConverter 上设置编解码器属性。
所以我做了:
AudioConverterSetProperty(acRef, kAudioCodecPropertyBitRateControlMode,
sizeof(control_mode), &control_mode);
AudioConverterSetProperty(acRef, kAudioCodecPropertyCurrentTargetBitRate,
sizeof(_bitRate), &_bitRate);