3

case 1: I am working on VOIP project where users can talk using their android smartphones. case 2: The same time i also want to record the voice & video on a device and save it on local sd card.

The problem is i am not able to record voice in case 2. Case 1 works fine and users are able to talk to each other. for case 1 i set "audio source" like this

 int audioSource = mSettings.isHandsetMode() ?
            MediaRecorder.AudioSource.DEFAULT : MediaRecorder.AudioSource.MIC;

and in case 2 i am setting "audio source" like this:

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void initRecorder() {
    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
    mMediaRecorder.setVideoEncodingBitRate(512 * 1000);
    mMediaRecorder.setVideoFrameRate(30);
    mMediaRecorder.setVideoSize(DisplayUtils.width(this), DisplayUtils.height(this));
    Random random=new Random();
    filename=new File(Environment.getExternalStorageDirectory(), random.nextInt() + ".mp4").getAbsolutePath();
    mMediaRecorder.setOutputFile(filename);
}

Here in "case 2" am not able to record voice & video. what could be the issue ?

fadden
  • 51,356
  • 5
  • 116
  • 166
Prakash
  • 357
  • 2
  • 14
  • The title says "recording audio using MediaProjection API" but the code shown in description is of MediaRecorder initialization. Also MediaProjection API doc is little bit misleading. it only records screen and not internal audio. and, MediaProjection API will record everything that is on the screen, not just the "Video" that you mentioned. i am not quite clear what you are trying to achieve. – Ankit Feb 27 '17 at 06:25

0 Answers0