1

I would like to record a video without having the preview but when I try to start I have this error message : "start failed: -38"

My code is (I used the code I found here to help me https://code.google.com/p/google-glass-api/issues/detail?id=360):

    // Step 1: Unlock and set camera to MediaRecorder
    mCamera.unlock();
    mMediaRecorder.setCamera(mCamera);

    // Step 2: Set sources
    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    // Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
    mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));

    // Step 4: Set output file
    mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO)
            .toString());
    // Step 5: Set the preview output
    // mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());

    // Step 6: Prepare configured MediaRecorder
    try {
        mMediaRecorder.prepare();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // Step 7: Start recording
    mMediaRecorder.start(); // HERE it fails

Thanks for your help

jan
  • 13
  • 1
  • 5

2 Answers2

0

Here's your answer: MediaRecorder start failed: -38

Another app (possibly yours?) is using the media recorder at the same time.

Community
  • 1
  • 1
Pedro Loureiro
  • 11,436
  • 2
  • 31
  • 37
0

In my case, I was trying to use some camera parameters for high fps (only work on recent Samsung phones, tested on S6):

 parameters.set("fast-fps-mode", 2); // 2 for 120fps
 parameters.setPreviewFpsRange(120000, 120000);

But I was always getting a black screen when trying to record with this error:

E/MediaRecorder: start failed: -38

The solution was simply to add:

parameters.setRecordingHint(true);

Hope it can help.

fxhereng
  • 11
  • 5