微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 如何实现“慢动作录像”的功能 ?

如何实现“慢动作录像”的功能 ?

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
慢动作录像——录像时按30fps录像,但播放时只播放20fps或15fps(在录像时选择),也就是说播放时有慢动作的效果。
[SOLUTION]
因为视频文件里面会存一个信息叫做timescale,解释如下:
timescale——specifiesthetime-scalefortheentirepresentation;thisis
thenumberoftimeunitsthatpassinonesecond.Ourplatformwillsetthisas1000whenrecord.
所以最简单的方式就在在录像结束更新MoovBox的时候修改timescale,值越小,相当于时间跑的越慢,这就达到了播放
时慢动作的效果了。
具体修改(SampleCode,30fps录像,15fps播放):
添加mSlowerVideoRecording&mWriterSlowerVideoRecording相关的代码即可.
1.php?mod=tag&id=6090" target="_blank" class="relatedlink">Frameworks\av\media\libmediaplayerservice\StagefrightRecorder.cpp
因为慢动作录像无法录制声音,所以需要将声音屏蔽掉。
boolmSlowerVideoRecording=true;
status_tStagefrightRecorder::setupMPEG4Recording()
{
...
//Audiosourceisaddedattheendifitexists.
//Thishelpmakesurethatthe"recoding"soundissuppressedfor
//camcorderapplicationsintherecordedfiles.
if(!mSlowerVideoRecording&&!mCaptureTimeLapse&&(mAudioSource!=AUDIO_SOURCE_CNT)){
err=setupAudioEncoder(writer);
if(err!=OK)returnerr;
*totalBitRate+=mAudioBitRate;
}
...
}
2.frameworks\av\media\libmediaplayerservice\MPEG4Writer.cpp
boolmWriterSlowerVideoRecording=true;
voidMPEG4Writer::writeMvhdBox(int64_tdurationUs){
int32_tmTempTimeScale=0;
...
if(mWriterSlowerVideoRecording)
mTempTimeScale=mTimeScale/2;
writeInt32(mTempTimeScale);//mvhdtimescale
int32_tduration=(durationUs*mTimeScale+5E5)/1E6;
...
}
voidMPEG4Writer::Track::writeMdhdBox(time_tnow){
int32_tmTempTimeScale=0;
...
if(mWriterSlowerVideoRecording)
mTempTimeScale=mTimeScale/2;
mOwner->writeInt32(mTempTimeScale);//mediatimescale
int32_tmdhdDuration=(trakDurationUs*mTimeScale+5E5)/1E6
...
}
3. 如何编译?
./mk mm frameworks/av/media/libmediaplayerservice/
./mk mm frameworks/av/media/libstagefright/
4. Push对应的.so到手机里面。
adb remount
adb push libstagefright.so /system/lib
adb push libmediaplayerservice.so /system/lib
adb reboot

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top