【问题标题】:Packet size (mBytesPerPacket) or the bitrate for AAC files in Core Audio数据包大小 (mBytesPerPacket) 或 Core Audio 中 AAC 文件的比特率
【发布时间】:2017-06-01 20:50:48
【问题描述】:

我想用恒定比特率 AAC 类型配置AudioStreamBasicDescription

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;

对于mBytesPerPacketApple 文档说:

音频数据包中的字节数。表示变量 数据包大小,将此字段设置为 0。对于使用变量的格式 数据包大小,使用一个指定每个数据包的大小 AudioStreamPacketDescription 结构。

我想把它作为一个常数,所以我必须在那里插入一个非零值(所需的大小),但是除了 0 之外的所有内容都失败了。

有什么帮助吗?

【问题讨论】:

  • 它是如何失败的?将 mBytesPerPacket 保留为 0。AAC 确实具有可变数据包大小。
  • 你是对的@RhythmicFistman。这是我的错

标签: c++ macos core-audio audio-processing bitrate


【解决方案1】:

事实证明,我们可以直接在 AudioConverter 上设置编解码器属性。

所以我做到了:

AudioConverterSetProperty(acRef, kAudioCodecPropertyBitRateControlMode,
                                                  sizeof(control_mode), &control_mode);

AudioConverterSetProperty(acRef, kAudioCodecPropertyCurrentTargetBitRate,
                                                  sizeof(_bitRate), &_bitRate);

【讨论】:

    猜你喜欢
    • 2020-03-29
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 2015-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    相关资源
    最近更新 更多