I have written an opensource camera for Google glass but some of the people who have used it have reported that the video recorded doesn't get saved properly for lengthy videos.
I couldn't find info regarding any such limitation in the Android documentation
So Upon checking it out i found that for videos greater than 26 minutes
, the video file got saved in Glass and Its size was around 2.7 GB
but its duration was 0:00
. And it couldn't be played using any video player.
So i am wondering why is that? Why does the video get properly recorded for duration < 26 minutes
and gets messed up for longer videos.
Code to start video Recording is
/**
* 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());
}
}
According to my research it seems that Google glass is only capable of recording video under 2GB
size so if you want to record any video whose size might be greater than that then i would advise you to divide the video into smaller parts and then at the end merge it with mp4 parser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With