Reputation: 11571
I am trying to a create video recorder in android using MediaRecorder where user will have an option to record mute video i.e recording video without audio. I checked if there is any option to record mute video in android & after lot of searching i didn't get any perfect way to do this, I tried below methods of AudioManager as well:
audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
audioManager.setMicrophoneMute(true);
audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE)
But none of them is working for me.
Can anyone help me to get this issue solved.
Thanks !!!
Upvotes: 3
Views: 3209
Reputation: 163
Here's how I dealt with it.
boolean settingsSound = sharedPrefSettings.getBoolean("settingsSound", true);
if (!settingsSound) {
mediarecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediarecorder.setVideoFrameRate(profile.videoFrameRate);
mediarecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
mediarecorder.setVideoEncodingBitRate(profile.videoBitRate);
mediarecorder.setVideoEncoder(profile.videoCodec);
} else{
mediarecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mediarecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediarecorder.setVideoFrameRate(profile.videoFrameRate);
mediarecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
mediarecorder.setVideoEncodingBitRate(profile.videoBitRate);
mediarecorder.setAudioEncodingBitRate(profile.audioBitRate);
mediarecorder.setAudioChannels(profile.audioChannels);
mediarecorder.setAudioSamplingRate(profile.audioSampleRate);
mediarecorder.setVideoEncoder(profile.videoCodec);
mediarecorder.setAudioEncoder(profile.audioCodec);
}
Just do not set audiosource. I'm getting profile like this
profile = CamcorderProfile.get(CamcorderProfile.QUALITY_1080P);
as there's no possibility to set CamcorderProfile without the sound, You need to set every value one by one.
Hope this will help :)
Upvotes: 5