Long time no article, in fact, is to record their own development in the Android growth process. Talking about the audio and video this piece, for the novice just contact this piece, it is very very disgusting ~ I myself get this piece is also from the beginning, in the Internet also read countless information, browse countless blog, tried a variety of methods, online general method is adopted third party, such as WEBRTC, Speex and so on. Even spend money to buy points to the next demo, also found a lot of demo is cheat points, hehe ~ angry ~ Not talk about. The process of growing up is also more difficult, and finally also solve the problem yourself ~ ~ Also hope this article can help in the same situation at the time of my.
1.Android sound recording 1. Using Audiorecord to record sound in Android, recording sound in Android requires the appropriate permissions, note the issue of dynamic request for permissions (more than 6.0).[HTML]View PlainCopy
Handling Permission Request callbacks
@Override
public void Onrequestpermissionsresult (int requestcode, string[] permissions, int[] grantresults) {
LOG.V (TAG, "processing permission request callback");
Permissionutils.requestpermissionsresult (Activitycameraliveview.this, Requestcode, permissions, GrantResults, Mpermissiongrant);
}
Private permissionutils.permissiongrant mpermissiongrant = new Permissionutils.permissiongrant () {
@Override
public void onpermissiongranted (int requestcode) {
Switch (requestcode) {
Case Permissionutils.code_record_audio:
LOG.V (TAG, "permissiongrant:code_record_audio AUDIO = true");
audio = true;
Break
Case Permissionutils.code_read_external_storage:
write_external_storage_permission = true;
LOG.V (TAG, "permissiongrant: write_external_storage_permission = true");
Break
Case Permissionutils.code_stop_camera:
LOG.V (TAG, "Permissionutils.code_stop_camera");
Break
Case Permissionutils.code_write_external_storage:
Break
Case Permissionutils.code_access_coarse_location:
Break
}
}
};
2. The sampling rate needs to be set before recording the Audiorecord
[HTML]View PlainCopy
- Nminbufsize = audiorecord.getminbuffersize (8000,
- Audioformat.channel_in_mono,
- Audioformat.encoding_pcm_16bit);
2.Android echo Cancellation There are probably two types of echo cancellation on the Internet: 1. The audio is automatically removed from the voice_communication mode of Android. 2. Use third-party libraries for elimination (WEBRTC, Speex. ) to eliminate the echo. With third-party words, more trouble, and not good to achieve, with the effect is not very obvious, try a bit Speex, feel mobile phone and mobile phone side voice can also, but if it is mobile phone (APP) and hardware voice, it is necessary to consider the problem of the code stream format, because our company uses the G711 format of the audio stream , so you must first turn the PCM format and then go to the Speex format, and finally to 711 format. Really not, there is one is in the recording of the force to turn off the speaker, in the recording when the sound of the phone only recorded the voice of the speaker, but the effect is not very obvious, or there will be a noise of AIDS. Turn off the speakers
[HTML]View PlainCopy
-
- Audiomanager = (Audiomanager) mcontext.getsystemservice (Context.audio_service);
-
- Audiomanager.setspeakerphoneon (FALSE);
-
- Audiomanager.setstreamvolume (audiomanager.stream_voice_call, 0,
-
- Audiomanager.stream_voice_call);
-
- Audiomanager.setmode (Audiomanager.mode_in_call);
Here I recommend the first method, not only considering the adaptation of the mobile phone model, but also relatively simple to change a parameter:
[HTML]View PlainCopy
- Audiorecord = New Audiorecord (MediaRecorder.AudioSource.VOICE_COMMUNICATION, 8000,
- Audioformat.channel_in_mono, Audioformat.encoding_pcm_16bit, nminbufsize);
- Audiorecord.startrecording ();
There's basically no echo and no noise.
Http://blog.csdn.net/wl532882877/article/details/78296662?locationNum=5&fps=1
Android Audio and Video de-echo, noise reduction (Android voice capture and Echo Cancellation) (RPM)