Front Camera Video Capturing Distortion - Android

混江龙づ霸主 提交于 2019-12-22 18:45:11

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/33787682/front-camera-video-capturing-distortion-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!