选择720P或480P,录制出来的视 频在电脑上播放很快,手机上播放正常
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
将720P和480P录像时声音的编码器替换为AAC之后现出这个问题,具体现象如下:
1、使用暴风影音播放,画面会跳,时间变化是:0,1,3,5,6,8,9
2、使用QuickTime,VLC,QQ影音,手机播放,表现都是正常的,时间变化也正常。
将有问题的视频去掉AudIOTrack(将AudioTrack的”hdlr”boxhandler_type改成非”soun”)之后,在暴风影音上播
放时间和画面都正常了,说明Decode图像画面以及VideoTrack是OK的。
[SOLUTION]
这个问题产生的原因是:
ICS & ICS2上AudioSource分配的buffersize比较大,AACEncode一次帧个数不均匀,encode一次可能会有2帧或1帧,这
样给writer的timestamp值是不均匀的,而在JB上每次只encode一帧timestamp比较均匀,因此暴风播起来正常,怀疑暴
风处理AACEncode帧timestamp不均匀的情况只能对一帧一个timestamp来处理。
php?mod=tag&id=6090" target="_blank" class="relatedlink">Frameworks\base\media\libstagefright\AudioSource.cpp文件中将构造函数修改成如下形式(修改蓝色代码):
AudioSource::AudioSource(
intinputSource,uint32_tsampleRate,uint32_tchannels)
:mStarted(false),
mSampleRate(sampleRate),
mPrevSampleTimeUs(0),
mNumFramesReceived(0),
mNumCLIentOwnedBuffers(0){
LOGV("sampleRate:%d,channels:%d",sampleRate,channels);
CHECK(channels==1||channels==2);
intminFrameCount;
status_tstatus=AudioRecord::getMinFrameCount(&minFrameCount,
sampleRate,
AUDIO_FORMAT_PCM_16_BIT,
channels);
if(status==OK){
//makesurethattheAudioRecordcallbackneverreturnsmorethanthemaximum
//buffersize
intframeCount=kMaxBufferSize/sizeof(int16_t)/channels;
//makesurethattheAudioRecordtotalbuffersizeislargeenough
intbufCount=2;
while((bufCount*frameCount)<minFrameCount){
bufCount++;
}
uint32_tflags=AudioRecord::RECORD_AGC_ENABLE|
AudioRecord::RECORD_NS_ENABLE|
AudioRecord::RECORD_IIR_ENABLE;
mRecord=newAudioRecord(
inputSource,sampleRate,AUDIO_FORMAT_PCM_16_BIT,
channels>1?AUDIO_CHANNEL_IN_STEREO:AUDIO_CHANNEL_IN_MONO,
bufCount*frameCount,
flags,
AudioRecordCallbackFunction,
this);
mInitCheck=mRecord->initCheck();
}else{
mInitCheck=status;
}
}
将720P和480P录像时声音的编码器替换为AAC之后现出这个问题,具体现象如下:
1、使用暴风影音播放,画面会跳,时间变化是:0,1,3,5,6,8,9
2、使用QuickTime,VLC,QQ影音,手机播放,表现都是正常的,时间变化也正常。
将有问题的视频去掉AudIOTrack(将AudioTrack的”hdlr”boxhandler_type改成非”soun”)之后,在暴风影音上播
放时间和画面都正常了,说明Decode图像画面以及VideoTrack是OK的。
[SOLUTION]
这个问题产生的原因是:
ICS & ICS2上AudioSource分配的buffersize比较大,AACEncode一次帧个数不均匀,encode一次可能会有2帧或1帧,这
样给writer的timestamp值是不均匀的,而在JB上每次只encode一帧timestamp比较均匀,因此暴风播起来正常,怀疑暴
风处理AACEncode帧timestamp不均匀的情况只能对一帧一个timestamp来处理。
php?mod=tag&id=6090" target="_blank" class="relatedlink">Frameworks\base\media\libstagefright\AudioSource.cpp文件中将构造函数修改成如下形式(修改蓝色代码):
AudioSource::AudioSource(
intinputSource,uint32_tsampleRate,uint32_tchannels)
:mStarted(false),
mSampleRate(sampleRate),
mPrevSampleTimeUs(0),
mNumFramesReceived(0),
mNumCLIentOwnedBuffers(0){
LOGV("sampleRate:%d,channels:%d",sampleRate,channels);
CHECK(channels==1||channels==2);
intminFrameCount;
status_tstatus=AudioRecord::getMinFrameCount(&minFrameCount,
sampleRate,
AUDIO_FORMAT_PCM_16_BIT,
channels);
if(status==OK){
//makesurethattheAudioRecordcallbackneverreturnsmorethanthemaximum
//buffersize
intframeCount=kMaxBufferSize/sizeof(int16_t)/channels;
//makesurethattheAudioRecordtotalbuffersizeislargeenough
intbufCount=2;
while((bufCount*frameCount)<minFrameCount){
bufCount++;
}
uint32_tflags=AudioRecord::RECORD_AGC_ENABLE|
AudioRecord::RECORD_NS_ENABLE|
AudioRecord::RECORD_IIR_ENABLE;
mRecord=newAudioRecord(
inputSource,sampleRate,AUDIO_FORMAT_PCM_16_BIT,
channels>1?AUDIO_CHANNEL_IN_STEREO:AUDIO_CHANNEL_IN_MONO,
bufCount*frameCount,
flags,
AudioRecordCallbackFunction,
this);
mInitCheck=mRecord->initCheck();
}else{
mInitCheck=status;
}
}
飘过