Erreur de démarrage de l’enregistrement multimédia Android a échoué -19 runTimeException

Je rencontre un problème avec mon enregistrement multimédia. J’essaie d’utiliser l’appareil photo avant pour enregistrer. Cela me donne une erreur (mais l’aperçu fonctionne). À chaque fois que j’utilise la caméra de recul, tout fonctionne correctement, je trouve cela très étrange. Quel pourrait être le problème et quelle pourrait être la solution? Mon code et les erreurs sont indiqués ci-dessous.

Modifier. Enregistrer avec une caméra frontale vga ne semble pas fonctionner. Comment est-ce possible? Bien que l’enregistrement avec l’application appareil photo HTC est possible.

Vous remerciant à l’avance.

protected void startRecording() throws Exception { mrec = new MediaRecorder(); mCamera.unlock(); mrec.setCamera(mCamera); mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA); mrec.setAudioSource(MediaRecorder.AudioSource.MIC); mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); //mrec.setPreviewDisplay(surfaceHolder.getSurface()); File picDirectory = new File(Environment.getExternalStorageDirectory() +"/TrouwApp"); picDirectory.mkdirs(); File mediaStorageDir = new File(Environment.getExternalStorageDirectory() +"/TrouwApp", "Videos"); // Create the storage directory if it does not exist if (! mediaStorageDir.exists()){ if (! mediaStorageDir.mkdirs()){ Log.d("MyCameraApp", "failed to create directory"); } } mrec.setOutputFile( mediaStorageDir.getPath() + File.separator + date + "_" + videonr+ ".3gp"); mrec.prepare(); mrec.start();//line 136 Log.d(TAG, "Recording started!!"); } 

lignes ajoutées au manifeste:

     

errorlog:

  08-25 23: 25: 25.332: V / MediaRecorderJNI (4989): configuration
 08-25 23: 25: 25.362: V / MediaRecorder (4989): constructeur
 08-25 23: 25: 25.402: V / MediaRecorder (4989): doCleanUp
 08-25 23: 25: 25.402: V / MediaRecorder (4989): setListener
 08-25 23: 25: 25.402: V / MediaRecorderJNI (4989): setMediaRecorder E: mr = mr
 08-25 23: 25: 25.402: V / MediaRecorderJNI (4989): setMediaRecorder X
 08-25 23: 25: 25.402: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.402: V / MediaRecorderJNI (4989): JNIMediaRecorderListener :: setCamera
 08-25 23: 25: 25.402: V / MediaRecorder (4989): setCamera (0x16c2290,0x1c08dc8)
 08-25 23: 25: 25.402: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.402: V / MediaRecorderJNI (4989): setVideoSource (1)
 08-25 23: 25: 25.402: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.402: V / MediaRecorder (4989): setVideoSource (1)
 08-25 23: 25: 25.402: V / MediaRecorder (4989): Appelez init () puisque l'enregistreur multimédia n'est pas encore initialisé
 08-25 23: 25: 25.402: V / MediaRecorder (4989): init
 08-25 23: 25: 25.412: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.412: V / MediaRecorderJNI (4989): setAudioSource (1)
 08-25 23: 25: 25.412: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.412: V / MediaRecorder (4989): setAudioSource (1)
 08-25 23: 25: 25.412: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): setOutputFormat (2)
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.502: V / MediaRecorder (4989): setOutputFormat (2)
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): setVideoFrameRate (30)
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.502: V / MediaRecorder (4989): setVideoFrameRate (30)
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): setVideoSize (1920, 1088)
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.502: V / MediaRecorder (4989): setVideoSize (1920, 1088)
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): setParameter ()
 08-25 23: 25: 25.502: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.502: V / MediaRecorder (4989): setParameters (débit-vidéo-param-encodage-vidéo = 12000000)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): setVideoEncoder (2)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.512: V / MediaRecorder (4989): setVideoEncoder (2)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): setParameter ()
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.512: V / MediaRecorder (4989): setParameters (débit-audio-param-encodage = 96000)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): setParameter ()
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.512: V / MediaRecorder (4989): setParameters (nombre-de-canaux-audio-audio = 1)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): setParameter ()
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.512: V / MediaRecorder (4989): setParameters (taux d'échantillonnage audio-param = 48000)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): setAudioEncoder (3)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.512: V / MediaRecorder (4989): setAudioEncoder (3)
 08-25 23: 25: 25.512: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.542: V / MediaRecorderJNI (4989): setOutputFile
 08-25 23: 25: 25.542: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.542: V / MediaRecorder (4989): setOutputFile (60, 0, 0)
 08-25 23: 25: 25.542: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.542: V / MediaRecorderJNI (4989): préparer
 08-25 23: 25: 25.542: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.542: V / MediaRecorder (4989): préparer
 08-25 23: 25: 25.542: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.542: V / MediaRecorderJNI (4989): début
 08-25 23: 25: 25.552: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 25.552: V / MediaRecorder (4989): début
 08-25 23: 25: 25.562: E / MediaRecorder (4989): échec du démarrage: -19
 08-25 23: 25: 25.562: V / MediaRecorderJNI (4989): process_media_recorder_call
 08-25 23: 25: 25.562: E / MediaRecorder (4989): le démarrage a échoué.
 08-25 23: 25: 25.562: E / MediaRecorder (4989): essayez de supprimer le fichier endommagé: /mnt/sdcard/TrouwApp/Videos/25-8-2013_0.3gp
 08-25 23: 25: 25.562: D / videoActivity (4989): le démarrage de ERROR a échoué.
 08-25 23: 25: 25.562: D / videoActivity (4989): ERREUR java.lang.RuntimeException: le démarrage a échoué.
 08-25 23: 25: 25.562: D / videoActivity (4989): ERREUR java.lang.RuntimeException: le démarrage a échoué.
 08-25 23: 25: 25.562: V / MediaRecorderJNI (4989): publication
 08-25 23: 25: 25.562: V / MediaRecorderJNI (4989): setMediaRecorder E: mr = null
 08-25 23: 25: 25.562: V / MediaRecorderJNI (4989): setMediaRecorder X
 08-25 23: 25: 25.562: V / MediaRecorder (4989): setListener
 08-25 23: 25: 25.562: V / MediaRecorder (4989): publication
 08-25 23: 25: 25.562: V / MediaRecorder (4989): destructeur
 08-25 23: 25: 25.562: D / videoActivity (4989): DÉBUT DE L'ENREGISTREMENT
 08-25 23: 25: 25.562: W / System.err (4989): java.lang.RuntimeException: le démarrage a échoué.
 08-25 23: 25: 25.572: W / System.err (4989): à l'adresse android.media.MediaRecorder._start (méthode native)
 08-25 23: 25: 25.572: W / System.err (4989): à android.media.MediaRecorder.start (MediaRecorder.java:712)
 08-25 23: 25: 25.572: W / System.err (4989): à l'adresse com.example.trouwapp.VideoActivity.startRecording (VideoActivity.java:136)
 08-25 23: 25: 25.572: W / System.err (4989): à l'adresse com.example.trouwapp.VideoActivity.onClick (VideoActivity.java:246)
 08-25 23: 25: 25.572: W / System.err (4989): à l'adresse android.view.View.performClick (View.java:3549)
 08-25 23: 25: 25.572: W / System.err (4989): sur android.view.View $ PerformClick.run (View.java:14393)
 08-25 23: 25: 25.582: W / System.err (4989): sur android.os.Handler.handleCallback (Handler.java:605)
 08-25 23: 25: 25.582: W / System.err (4989): à android.os.Handler.dispatchMessage (Handler.java:92)
 08-25 23: 25: 25.582: W / System.err (4989): sur android.os.Looper.loop (Looper.java:154)
 08-25 23: 25: 25.582: W / System.err (4989): à l'adresse android.app.ActivityThread.main (ActivityThread.java:4945)
 08-25 23: 25: 25.582: W / System.err (4989): à java.lang.reflect.Method.invokeNative (méthode native)
 08-25 23: 25: 25.582: W / System.err (4989): sur java.lang.reflect.Method.invoke (Method.java:511)
 08-25 23:25: 25.582: W / System.err (4989): sur com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:784)
 08-25 23: 25: 25.582: W / System.err (4989): sur com.android.internal.os.ZygoteInit.main (ZygoteInit.java:551)
 08-25 23: 25: 25.592: W / System.err (4989): sur dalvik.system.NativeStart.main (méthode native)
 08-25 23: 25: 55.582: V / MediaRecorderJNI (4989): native_reset
 08-25 23: 25: 55.582: V / MediaRecorderJNI (4989): getMediaRecorder E
 08-25 23: 25: 55.582: V / MediaRecorderJNI (4989): publication
 08-25 23: 25: 55.582: V / MediaRecorderJNI (4989): setMediaRecorder E: mr = null
 08-25 23: 25: 55.582: V / MediaRecorderJNI (4989): setMediaRecorder X
 08-25 23: 25: 56.002: D / AndroidRuntime (4989): arrêt de la machine virtuelle
 08-25 23: 25: 56.002: W / dalvikvm (4989): ID_fil = 1: thread sortant avec une exception non capturée (groupe = 0x40ac8228) 

Trouvé la solution. Depuis que j’utilise l’appareil photo avant, j’ai besoin d’obtenir le profil du caméscope à partir de l’appareil photo avant. J’ai réalisé cela en faisant ceci:

 mrec.setProfile(CamcorderProfile.get(1, CamcorderProfile.QUALITY_HIGH)); 

Au lieu de cela:

 mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); 

essaye ça:

 StartRecording = false; if( mrec == null ) { mrec = new MediaRecorder(); mCamera.unlock(); mrec.setCamera(mCamera); File picDirectory = new File(Environment.getExternalStorageDirectory() +"/TrouwApp"); picDirectory.mkdirs(); File mediaStorageDir = new File(Environment.getExternalStorageDirectory() +"/TrouwApp", "Videos"); mrec.setAudioSource(MediaRecorder.AudioSource.MIC); mrec.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); //you forgot this mrec.setOutputFile( mediaStorageDir.getPath() + File.separator + date + "_" + videonr+ ".3gp"); mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); //you forgot this also mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA); mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); } if(!StartRecording) { Log.d(TAG, "Recording stopped!!"); try { mrec.prepare(); mrec.start(); StartRecording = true; } catch (IOException e) { e.printStackTrace(); } } else { Log.d(TAG, "Recording started!!"); StartRecording = false; mrec.stop(); mrec.reset(); mrec.release(); mrec = null; }//else