Android Media Recorder not recording long videos on Google Glass

Spread the love

Question Description

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()) {
        videofile = new File(dir, "video.mp4");

        // Step 2: Set sources

        // Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
        // Step 4: Set output file
        // Step 5: Set the preview output
        // Step 6: Prepare configured MediaRecorder
        recorder.setMaxDuration(3600* 1000);
        recorder.setOnErrorListener(new OnErrorListener() {

            public void onError(MediaRecorder mr, int what, int extra) {
            Log.e("Error Recording", what+" Extra "+extra);

        recorder.setOnInfoListener(new OnInfoListener() {

            public void onInfo(MediaRecorder mr, int what, int extra) {
                if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {



    } catch (Exception e) {
        if (e != null && e.getMessage() != null)
            Log.e("Error Starting CuXtom Camera for video recording",

Practice As Follows

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

You may be interested in these books.


As an Amazon Associate I earn from qualifying purchases.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.