6

I am creating a custom camera application,and I have found a serious issue with Nexus 7. When I record the video with front camera, the recorded video is smooth and reproduces the same colors, but if the recording was done with Back Camera, the color reproduced are red changes to blue and yellow to cyan. This issue is happening only in Nexus 7. Can some one help out with a solution.

    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;
    }
fadden
  • 51,356
  • 5
  • 116
  • 166
Albin Mathew
  • 411
  • 1
  • 6
  • 13
  • Do you see the color changes in the preview window, the recorded video, or both? What version of Android, and which version of the Nexus 7 (2012 or 2013)? – fadden Aug 27 '15 at 14:36
  • I can see altered colors it in recorded video only, not in the preview that's shown while recording. Android Version 5.0.1 is running on the nexus 7 2013 model . – Albin Mathew Aug 29 '15 at 10:22
  • Sounds like something is getting the color format wrong -- something like http://stackoverflow.com/questions/13703596/mediacodec-and-camera-colorspaces-dont-match may be happening. – fadden Aug 29 '15 at 20:21

0 Answers0