How I can record video only with MediaRecorder? I found the solution that simply leaving out the AudioSource will do that but unfortunately doesn't work on Android 10+. If I do that MediaRecorder.prepare() fails. I can't find a solution on the internet.
Thanks
Prepare your media recorder in the following sequence. Only set AudioSource and AudioEncoder if you want to record with sound.
MediaRecorder mMediaRecorder = new MediaRecorder();
if (recordWithSound == true) {
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
}
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setVideoSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
if (recordWithSound == true) {
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
mMediaRecorder.setVideoEncodingBitRate(videoBitRate);
mMediaRecorder.setVideoFrameRate(videoFrameRate);
mMediaRecorder.setOrientationHint(orientation);
mMediaRecorder.setOutputFile(videoFile);
mMediaRecorder.prepare();