如何填充 AudioStreamBasicDescription 以进行 AMR 播放
源数据是 AMR-NB 5.9kbit/s (AMR_5.90)
我已经尝试了以下设置(和十几个变体),但我得到的只是垃圾音频。有谁知道 AMR 的正确设置吗?
AudioStreamBasicDescription asbd;
asbd.mSampleRate = 8000.0;
asbd.mFormatID = kAudioFormatAMR;
asbd.mFormatFlags = 0;
asbd.mBytesPerPacket = 15; // (118>>3)
asbd.mFramesPerPacket = 1;
asbd.mBytesPerFrame = 15;
asbd.mChannelsPerFrame = 1;
asbd.mBitsPerChannel = 118; //tried also 0 and 13
asbd.mReserved = 0;
基于 AMR 维基百科的信息:
采样频率 8 kHz/13 位(20 ms 帧 160 个样本)
生成长度为 95、103、118、134、148、159、204 或 244 位的帧,比特率为 4.75,分别为 5.15、5.90、6.70、7.40、7.95、10.2 或 12.2 kbit/s
数据结构描述来自此处:
source data is AMR-NB 5.9kbit/s (AMR_5.90)
I've tried the below settings (and a dozen variations) but I'm getting nothing more than garbage audio. Does anyone know the correct settings for AMR?
AudioStreamBasicDescription asbd;
asbd.mSampleRate = 8000.0;
asbd.mFormatID = kAudioFormatAMR;
asbd.mFormatFlags = 0;
asbd.mBytesPerPacket = 15; // (118>>3)
asbd.mFramesPerPacket = 1;
asbd.mBytesPerFrame = 15;
asbd.mChannelsPerFrame = 1;
asbd.mBitsPerChannel = 118; //tried also 0 and 13
asbd.mReserved = 0;
Based on info from wikipedia for AMR:
Sampling frequency 8 kHz/13-bit (160 samples for 20 ms frames)
Generates frame length of 95, 103, 118, 134, 148, 159, 204, or 244 bits for bit rates 4.75, 5.15, 5.90, 6.70, 7.40, 7.95, 10.2, or 12.2 kbit/s, respectively
And the data structure description from here:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iOS 放弃了 AMR 支持,因此新的解决方案是使用 OpenCoreAMR 将数据转换为 PCM
iOS dropped AMR support, so the new solution is to use OpenCoreAMR to convert data to PCM