2012-05-08 39 views
0

我一直在嘗試創建一個應用程序,用於將視頻記錄並上傳到S3存儲桶。 我一直在使用(有點改變)Android capture video intent article。但是當錄音結束時,我會收到錯誤列表。 (我使用的是Galaxy S2手機,因此支持)。嘗試錄製視頻時出現VerifiyAndSetParameter錯誤

代碼CameraActivity:

 Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); 
     fileUri = SavingMedia 
       .getOutputMediaFileUri(SavingMedia.MEDIA_TYPE_VIDEO); 
     path = fileUri.toString(); 

     intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30); 
     intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 
     intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, 
       ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
     intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0.2); 

     startActivityForResult(intent, CAPTURE_VIDEO_REQUEST_CODE); 

logcat的輸出:

05-08 10:46:31.875: E/CameraInput(2595): Recording is not ready (iPeer 0xfbb3c iState 2 iWriteState 1 iClockState 0), frame dropped 
05-08 10:46:31.910: E/CameraInput(2595): Recording is not ready (iPeer 0xfbb3c iState 2 iWriteState 1 iClockState 0), frame dropped 
05-08 10:46:31.945: E/CameraInput(2595): Recording is not ready (iPeer 0xfbb3c iState 2 iWriteState 1 iClockState 0), frame dropped 
05-08 10:46:31.975: E/CameraInput(2595): Recording is not ready (iPeer 0xfbb3c iState 2 iWriteState 1 iClockState 0), frame dropped 
05-08 10:46:33.455: E/yamaha::media::Parameters(2595): SalesCode = PTR 
05-08 10:46:33.705: E/CameraInput(2595): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value) 
05-08 10:46:33.705: E/CameraInput(2595): VerifiyAndSetParameter failed on parameter #0 
05-08 10:46:33.705: E/audio_input(2595): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value 
05-08 10:46:33.705: E/audio_input(2595): VerifyAndSetParameter failed 
05-08 10:46:33.740: E/AndroidRuntime(29786): FATAL EXCEPTION: main 
05-08 10:46:33.740: E/AndroidRuntime(29786): java.lang.NullPointerException 
05-08 10:46:33.740: E/AndroidRuntime(29786): at java.io.File.fixSlashes(File.java:205) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at java.io.File.init(File.java:189) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at java.io.File.<init>(File.java:139) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.sec.android.app.camera.CamcorderEngine.renameTempFile(CamcorderEngine.java:1206) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.sec.android.app.camera.CamcorderEngine.doStopVideoRecordingSync(CamcorderEngine.java:812) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.sec.android.app.camera.CeStateRecording.handleRequest(CeStateRecording.java:69) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.sec.android.app.camera.CeRequestQueue.startFirstRequest(CeRequestQueue.java:123) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.sec.android.app.camera.CeRequestQueue.access$200(CeRequestQueue.java:32) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.sec.android.app.camera.CeRequestQueue$MainHandler.handleMessage(CeRequestQueue.java:60) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at android.os.Handler.dispatchMessage(Handler.java:99) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at android.os.Looper.loop(Looper.java:123) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at android.app.ActivityThread.main(ActivityThread.java:3691) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at java.lang.reflect.Method.invokeNative(Native Method) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at java.lang.reflect.Method.invoke(Method.java:507) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 
05-08 10:46:33.740: E/AndroidRuntime(29786): at dalvik.system.NativeStart.main(Native Method) 
05-08 10:46:33.770: E/(2806): Dumpstate > /data/log/dumpstate_app_error 

回答

2

哥們你應該看到以下問題, 它正在爲我和你肯定工作的答案。

Android: Video Recording Throws Error

注:我有同樣的錯誤在com.sec.android.app.camera.CamcorderEngine.renameTempFile(CamcorderEngine.java:1206)

解決方案如下

:在工作Android 2.2系統,2.3 ... 我已經做了以下過程拍攝照片

int CAMERA_WITH_VIDEO_DATA = 2; 
//start photo capture activity... 

Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE, null); 
startActivityForResult(intent, CAMERA_WITH_VIDEO_DATA); 

.... 
.... 

private void saveVideoFileOnActivityResult(Intent videoIntent){ 
    FileInputStream fis = null; 
    FileOutputStream fos = null; 
    File mCurrentVideoFile = null; 
    try { 
     mCurrentVideoFile = new File("path_to_your_file"); 
     AssetFileDescriptor videoAsset = getContentResolver().openAssetFileDescriptor(videoIntent.getData(), "r"); 
     fis = videoAsset.createInputStream(); 
     //File videoFile = new File(Environment.getExternalStorageDirectory(),"<VideoFileName>.mp4"); 
     fos = new FileOutputStream(mCurrentVideoFile); 

     byte[] buffer = new byte[1024]; 
     int length; 
     while ((length = fis.read(buffer)) > 0) { 
       fos.write(buffer, 0, length); 
      }  
     //fis.close(); 
     //fos.close(); 
    } catch (IOException e) { 
     // TODO: handle error 
    e.printStackTrace(); 
    }finally{ 
     try { 
      if(fis!=null) 
       fis.close(); 
      if(fos!=null) 
       fos.close(); 
     } catch (Exception e2) { 
     // TODO: handle exception 
     e2.printStackTrace(); 
     } 
    } 
    } 
.... 
.... 

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
switch (requestCode) { 
case CAMERA_WITH_VIDEO_DATA: 
//pass data to above method to save it. 
saveVideoFileOnActivityResult(data); 
break; 

default: 
break; 
} 
} 
0

OK,我改進我的logcat看到錯誤開始的地方,並在其中的程序失敗,第一行是:

05-08 10:46:33.740: E/AndroidRuntime(29786): at com.sec.android.app.camera.CamcorderEngine.renameTempFile(CamcorderEngine.java:1206) 

快速谷歌搜索帶我到this place,顯然,MediaStore.EXTRA_OUTPUT正確不DOES工作並有問題。

這是一個寫有答案:

其實,我在一些情況下MediaStore.EXTRA_OUTPUT不能正常工作發現,讓對方招的辦法是,存儲捕獲的視頻文件在onActivityResult( )

protected void onActivityResult(int requestCode, int resultCode, Intent intent) { 
    super.onActivityResult(requestCode, resultCode, intent); 

    if (resultCode == RESULT_OK) { 
     try { 
      AssetFileDescriptor videoAsset = getContentResolver().openAssetFileDescriptor(intent.getData(), "r"); 
      FileInputStream fis = videoAsset.createInputStream(); 
      File videoFile = new File(Environment.getExternalStorageDirectory(),"<VideoFileName>.mp4"); 
      FileOutputStream fos = new FileOutputStream(videoFile); 

      byte[] buffer = new byte[1024]; 
      int length; 
      while ((length = fis.read(buffer)) > 0) { 
      fos.write(buffer, 0, length); 
     }  
     fis.close(); 
     fos.close(); 
     } catch (IOException e) { 
      // TODO: handle error 
     } 
    } 
}