Search code examples
androidfront-camera

Front Camera Video Capturing Distortion - Android


I am working on Video capturing App. It is working fine for back camera. But when i switch to front CAM the video made is very blur (just some line across the video).

    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_720P));

    mediaRecorder.setOutputFile("/sdcard/myvideo.mp4");
    mediaRecorder.setMaxDuration(600000); // Set max duration 60 sec.
    mediaRecorder.setMaxFileSize(50000000); // Set max file size 50M

Solution

  • I have searched a lot and eventually found the solution as below.

    The BitRate,setEncodingBitRate,setVideoFrameRate,setVideoSize functions can have parameters according to your or user-end devices. I have used constant values working fine for me. Set them generic accordingly. Also, Remember that camera resolution is also set LOW for Front Cameras.

        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
        mediaRecorder.setVideoEncodingBitRate(512* 1000);
        mediaRecorder.setVideoFrameRate(15);
        mediaRecorder.setVideoSize(640,480);
        mediaRecorder.setVideoSize( 200, 200 );
        mediaRecorder.setOutputFile("/sdcard/myvideo.mp4");
        mediaRecorder.setMaxDuration(600000); // Set max duration 60 sec.
        mediaRecorder.setMaxFileSize(50000000); // Set max file size 50M
    

    `Attaching Links which helped me to come to this solution. Blurr/Distorted video Error Insight