Nexus 7摄像机颜色识别问题

时间:2015-08-26 10:03:15

标签: android android-camera android-mediarecorder

我正在创建一个自定义相机应用程序,我发现了Nexus 7的一个严重问题。当我用前置摄像头录制视频时,录制的视频是平滑的并且再现相同的颜色,但是如果录制完成了Back相机,再现的颜色是红色变为蓝色和黄色变为青色。此问题仅在Nexus 7中发生。有人可以帮助解决方案。

    mMediaRecorder = new MediaRecorder();

    // Step 1: Unlock and set camera to MediaRecorder
    mCamera.unlock();
    mMediaRecorder.setCamera(mCamera);
    mMediaRecorder.setMaxDuration(25000);
    if (mCameraPosition == CameraInfo.CAMERA_FACING_FRONT) {

        if (orientation == Configuration.ORIENTATION_LANDSCAPE)
            mMediaRecorder.setOrientationHint(0);
        else if (orientation == Configuration.ORIENTATION_PORTRAIT)
            mMediaRecorder.setOrientationHint(270);
        else if (orientation == REVERSED_LANDSCAPE) {
            mMediaRecorder.setOrientationHint(180);
        } else {
            mMediaRecorder.setOrientationHint(90);
        }

    } else {

        if (orientation == Configuration.ORIENTATION_PORTRAIT) {
            mMediaRecorder.setOrientationHint(angle);
        } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            mMediaRecorder.setOrientationHint(0);
        } else if (orientation == REVERSED_LANDSCAPE) {
            mMediaRecorder.setOrientationHint(180);
        } else {
            mMediaRecorder.setOrientationHint(270);
        }

    }


    // 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(mCameraPosition,
            CamcorderProfile.QUALITY_720P));

    // 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) {
        e.printStackTrace();
        releaseMediaRecorder();
        return false;
    } catch (IOException e) {
        e.printStackTrace();
        releaseMediaRecorder();
        return false;
    }

0 个答案:

没有答案