When I record video by MediaRecorder, it always records in landscape mode, regardless of real device orientation. How to force MediaRecorder/Camera use real orientation ?
When I record video by MediaRecorder, it always records in landscape mode, regardless of real device orientation. How to force MediaRecorder/Camera use real orientation ?
Take a look at the documentation here
http://developer.android.com/guide/topics/media/camera.html#capture-video
The most common pitfall with the this example is the setCamera() . YOU MUST SET THE CAMERA IMMEDIATELY AFTER MAKING THE MediaRecorder otherwise you will get errors.
Camera mCamera = getCameraInstance();
// adjust the camera the way you need
mCamera.setDisplayOrientation(90);
MediaRecorder recorder = new MediaRecorder();
mCamera.unlock();
recorder.setCamera(mCamera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
recorder.setOutputFile(filePath);
// add any limits
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
I hope this helps someone. Good Luck!!