标签:android 源码 videoactor mpeg4write
录制视频需要分段保存,可以从系统源码考虑,看了以下一些代码:
主要从MPEG4Writer.cpp中的kMax32BitFileSize 和入手,如下,修改单个文件最大容量为56M(0x3800000),发现利用系统Camera录像时,到达阀值后会提示“已达到大小上限”,并自动停止,保存已经录制的视频。
static const int64_t kMax32BitFileSize = 0x3800000;//0x00ffffffffLL; // 2^32-1 : max FAT32
static const int64_t kMax32BitDuration = 0x007fffffffLL;
然后追踪到VideoActor的处理。有一个思路,就是停止的时候,进行文件保存后立即重新启动录像。
public void stopVideoRecordingAsync() { // TChip ZJ
// for snapshot
stopObjectTracking();
mStopVideoRecording = true;
Log.d(TAG, "stopVideoRecordingAsync() mMediaRecorderRecording=" + mMediaRecorderRecording
+ ", mRecorderBusy=" + mRecorderBusy
+ ", isVideoProcessing()" + isVideoProcessing()
+ ", mStopVideoRecording =" + mStopVideoRecording);
mVideoContext.getZoomManager().changeZoomForQuality();
mVideoContext.setSwipingEnabled(true);
mHandler.removeMessages(UPDATE_RECORD_TIME);
mVideoContext.getShutterManager().setVideoShutterMask(false);
if (isVideoProcessing()) {
return;
}
if (mRecorderBusy) { // return for recorder is busy.
return;
}
mRecorderBusy = true;
mRecordingView.hide();
if (mMediaRecorderRecording) {
mVideoContext.getShutterManager().setVideoShutterEnabled(false);
if (mStoppingAction != STOP_RETURN_UNVALID && mCallFromOnPause != true) {
// mVideoContext.showProgress(mVideoContext.getResources().getString(R.string.saving)); // TChip ZJ : 去掉保存UI
}
mVideoSavingTask = new SavingTask();
mVideoSavingTask.start();
} else {
mRecorderBusy = false;
releaseRecorder();
if (mStoppingAction == STOP_RETURN_UNVALID) {
doReturnToCaller(false);
}
}
}
先吃饭了,明天再看实现的可行性以及效果(是否漏秒)。
标签:android 源码 videoactor mpeg4write
原文地址:http://blog.csdn.net/zhoumushui/article/details/44346145