Home » Android » android – Custom camera recorder preview get stretched when MediaRecorder.start() gets called

android – Custom camera recorder preview get stretched when MediaRecorder.start() gets called

Posted by: admin May 14, 2020 Leave a comment

Questions:
recorder = new MediaRecorder();
camera.unlock();
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setProfile(CamcorderProfile.get(currentCamType,CamcorderProfile.QUALITY_HIGH)); 
recorder.setOutputFile(/*path of output file*/);
recorder.prepare();
recorder.start();

In the above code preview is getting changed(get stretched) when recorder.start() gets called yet I am not set the preview display of media recorder by MediaRecorder.setPreviewDisplay(). I have used camera.setPreviewDisplay() once when surface view is created. I think recorder.setProfile() in the above code is responsible for stretching the video.

How to&Answers: