androidgoogle-glassvideo-recordinggoogle-gdk

MediaRecorder, start failed: -19


Has anyone managed to successfully record a video using MediaRecorder on Glass?

This is the code i am using in order to prepare the Recorder. I keep getting error -19.

    recorder = new MediaRecorder();

    recorder.setOutputFile(videoFile);

    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);

    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

    recorder.setVideoFrameRate(15);
    recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);

    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); 

Thank you.

Update: It seems to be a GDK bug. I have reported it and it got accepted. If you are having the same issue just star the bug report to stay informed:

https://code.google.com/p/google-glass-api/issues/detail?id=360


Solution

  • To start video capture on Glass it seems that you have to completely stop the video preview. If you are using a previewing camera, prior of doing anything with a MediaRecorder, just run:

    try {
        mCamera.setPreviewDisplay(null);
    } catch (java.io.IOException ioe) {
        Log.d(TAG, "IOException nullifying preview display: " + ioe.getMessage());
    }
    mCamera.stopPreview();
    mCamera.unlock();
    

    More info here: https://code.google.com/p/google-glass-api/issues/detail?id=360#c6