Following is the code I use to record audio through MIC in .opus format. I'm always getting the error MediaRecorder: start failed: -38. But this will work fine if change the output format and audio encoder to any others like THREE_GPP,MPEG_4 with AAC or AMR. Since I need opus file type I cannot use any other audio formats. Since android has official support on opus over (Android 5.0+) device this should working. Correct me if i'm doing something wrong here.
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.VORBIS);
mRecorder.setOutputFile(fileName);
mRecorder.prepare();
mRecorder.start();