2014-03-26 56 views
1

我想錄制視頻,而無需在預覽,但是當我嘗試啓動我有這樣的錯誤消息:「啓動失敗:-38」錄製視頻錯誤:啓動失敗:-38

我的代碼(我用我發現這裏幫我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 

感謝您的幫助

+0

您是否嘗試將#6中提到的代碼添加到您的準備功能中? –

回答

0

以我爲例,我試圖用高fps的一些相機參數(僅在最近的三星手機,在S6測試工作):

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

但嘗試時,我總是得到一個黑色的屏幕與此錯誤記錄:

E/MediaRecorder: start failed: -38

的解決方案是簡單地添加:

parameters.setRecordingHint(true); 

希望它可以幫助。