我采集原始的PCM帧数据(16KHZ采样)用libfaac库编码成AAC帧(ADTS格式)
然后写成.aac文件,当我用播放器播放时发现声音比正常速度要快,移植找不到原因,望大神指导,万分感谢!
一些基本参数如下:
PCM : 16000HZ 160采样为1帧
//使用 faac 库
aac_config.EncHandle = faacEncOpen(aac_config.SampleRate, \
aac_config.Channels, \
&aac_config.InputSamples, \
&aac_config.MaxOutputBytes);
if(aac_config.EncHandle == NULL)
{
DEBUG_LOG("failed to call faacEncOpen()\n");
return NULL;
}
aac_config.PCMBuffer_size = aac_config.InputSamples * (aac_config.PCMBitSize / 8);//PCM_BUF_SIZE;
aac_config.PCMBuffer = (unsigned char*)malloc(aac_config.PCMBuffer_size * sizeof(unsigned char));
aac_config.AACBuffer = (unsigned char*)malloc(aac_config.MaxOutputBytes * sizeof(unsigned char));
memset(aac_config.PCMBuffer, 0, aac_config.PCMBuffer_size);
memset(aac_config.AACBuffer, 0, aac_config.MaxOutputBytes);
//获取当前配置参数
faacEncConfigurationPtr pConfiguration = faacEncGetCurrentConfiguration(aac_config.EncHandle);
//调整配置参数
#if 1
pConfiguration->inputFormat = FAAC_INPUT_16BIT;
pConfiguration->outputFormat = 1; /*0 - raw; 1 - ADTS*/
pConfiguration->bitRate = PCM_SAMPLE_RATE; //库内部默认为64000
pConfiguration->useTns = 0;
pConfiguration->allowMidside = 1;
pConfiguration->shortctl = SHORTCTL_NORMAL;
pConfiguration->aacObjectType = LOW;
pConfiguration->mpegVersion = MPEG4;//MPEG2
//pConfiguration->useLfe = 1;
#endif
//重新设置回去
ret = faacEncSetConfiguration(aac_config.EncHandle,pConfiguration);
if(ret != 1)
{
ERROR_LOG("failed to call faacEncSetConfiguration()\n");
return NULL;
}