2014-03-28 97 views
0

我正在錄製使用自定義媒體錄製器類和錄製視頻的一些設備工作正常,但一些設備創建0長度video.I不知道是什麼問題MediaRecording配置。媒體錄製問題Android

  Camera mcamera 
      mCamera.unlock(); 
      mrec.setCamera(mCamera); 
      mrec.setPreviewDisplay(surfaceHolder.getSurface()); 
      mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA); 
      mrec.setAudioSource(MediaRecorder.AudioSource.MIC); 
      if (cameraID != -1) { 
       mrec.setProfile(CamcorderProfile.get(cameraID, 
         CamcorderProfile.QUALITY_HIGH)); 
      } else { 
       mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); 
      } 

      mrec.setPreviewDisplay(surfaceHolder.getSurface()); 
      mrec.setOutputFile(filename); 

Plz幫助預先感謝。

我M還檢查hasprofile方式

CamcorderProfile profile = null; 

     if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_1080P)) 
      profile = CamcorderProfile.get(CamcorderProfile.QUALITY_1080P); 
     else if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_720P)) 
      profile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P); 
     else if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_480P)) 
      profile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P); 
     else if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_HIGH)) 
      profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); 

     if (cameraID != -1) { 
      mrec.setProfile(profile); 
       } 

但這種方式獲得問題的問題startunlock失敗。

+0

檢查我米更新發布@Michel但獲取記錄開始問題開始解鎖失敗 – Sanket990

回答

0

我敢肯定你得掉這些行:

 mrec.setOutputFile(filename); 
     mrec.setPreviewDisplay(surfaceHolder.getSurface()); 

現在,將它的工作原理?讓我知道!