14
我已經爲谷歌眼鏡寫了opensource camera,但一些使用過它的人報告說,錄製的視頻無法正確保存冗長的視頻。Android媒體錄製器沒有在Google Glass上記錄長視頻
我找不到信息有關Android文檔中的任何這樣的限制
所以一旦檢查出來我發現,對於視頻超過26 minutes
越大,視頻文件得到了保存在玻璃及其大小約爲2.7 GB
但其持續時間爲0:00
。它不能用任何視頻播放器播放。
所以我想知道爲什麼呢?爲什麼該視頻會被正確錄製爲duration < 26 minutes
,並因混淆視頻而變得混亂。
代碼開始錄像是
/**
* Initialize video recorder to record video
*/
private void initRecorder() {
try {
File dir = new File(Environment.getExternalStorageDirectory()
+ File.separator + Environment.DIRECTORY_PICTURES
+ File.separator + "My Videos");
if (!dir.exists()) {
dir.mkdirs();
}
videofile = new File(dir, "video.mp4");
recorder.setCamera(mCamera);
// Step 2: Set sources
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
recorder.setProfile(CamcorderProfile
.get(CamcorderProfile.QUALITY_HIGH));
// Step 4: Set output file
recorder.setOutputFile(videofile.getAbsolutePath());
// Step 5: Set the preview output
recorder.setPreviewDisplay(mPreview.getHolder().getSurface());
// Step 6: Prepare configured MediaRecorder
recorder.setMaxDuration(3600* 1000);
recorder.setMaxFileSize(-1);
recorder.setOnErrorListener(new OnErrorListener() {
@Override
public void onError(MediaRecorder mr, int what, int extra) {
Log.e("Error Recording", what+" Extra "+extra);
}
});
recorder.setOnInfoListener(new OnInfoListener() {
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
endVideoRecording();
}
}
});
recorder.prepare();
recorder.start();
mOverlay.setMode(Mode.RECORDING);
} catch (Exception e) {
if (e != null && e.getMessage() != null)
Log.e("Error Starting CuXtom Camera for video recording",
e.getMessage());
}
}