mardi 4 août 2015

Android: MediaRecorder start failed

I run my video recorder app on 30 type of phones are fine except for Samsung GT-I9082i. My app display the camera info. on a OpenGL view but not surface view. If I use surface view to dispaly the camera info. on GT-I9082i, all are OK. Because I must to render more efffects use opengl,I cann't use Surface view.

if (mMediaRecorder == null) {
            mMediaRecorder = new MediaRecorder();
        } else {
            mMediaRecorder.reset();
        }

mMediaRecorder.setCamera(camera);

        // Step 2: Set sources

        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);

        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

// Step 4: Set a CamcorderProfile (requires API Level 8 or higher)

        mMediaRecorder.setProfile(CamcorderProfile.get(cameraIndex, CamcorderProfile.QUALITY_HIGH));

mRecAudioFile = File.createTempFile("Video", ".mp4", mRecVedioPath);

mMediaRecorder.setOutputFile(mRecAudioFile.getAbsolutePath());

        // Step 6: Set the preview output

        mMediaRecorder.setPreviewDisplay(null);

        // Step 7: Set Video Size


        mMediaRecorder.setVideoSize(cameraVideoOptimalSize.width, cameraVideoOptimalSize.height);

// Step 8: Prepare configured MediaRecorder

        try {
            mMediaRecorder.prepare();
            mMediaRecorder.start();

        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

Aucun commentaire:

Enregistrer un commentaire