i attempting record audio on android , encounter issues quality, respectively chosen format.
i use following setup
mr=new mediarecorder(); mr.setaudiosource(mediarecorder.audiosource.mic); mr.setoutputformat(mediarecorder.outputformat.mpeg_4); mr.setoutputfile("somepath"); mr.setaudioencoder(mediarecorder.audioencoder.aac);
that code returns different results on 2 devices running different android versions (4.4.4 , 5.1.1).
when take @ file headers, shows different formats both files there (3gp4 on 4.4.4 - mp42 on 5.1.1). vlc "insists" on both using aac, shows different sampling rates, 8k 4.4.4 file , 48k 5.1.1.
anybody idea why?
try set of this:
recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(mediarecorder.outputformat.mpeg_4); recorder.setaudioencoder(mediarecorder.audioencoder.aac); //i use mediarecorder.audioencoder.amr_nb recorder.setaudioencodingbitrate(16); recorder.setaudiosamplingrate(44100); recorder.setoutputfile(outputfile.getabsolutepath()); recorder.prepare(); recorder.start();
or use external library: http://rehearsalassist.svn.sourceforge.net/viewvc/rehearsalassist/android/releases/rehearsalassistant_0_8_2/src/urbanstew/rehearsalassistant/
by changing recorder:
rehearsalaudiorecorder recorder = new rehearsalaudiorecorder(rehearsalaudiorecorder.recording_uncompressed, mediarecorder.audiosource.mic, 44100, audioformat.channel_configuration_stereo, audioformat.encoding_pcm_16bit); recorder.setoutputfile(outputfile.getabsolutepath()); recorder.prepare(); recorder.start();
update
check this:
mediarecorder recorder = new mediarecorder(); recorder.setaudiosource(mediarecorder.audiosource.mic); if (build.version.sdk_int >= 10) { recorder.setaudiosamplingrate(44100); recorder.setaudioencodingbitrate(96000); recorder.setoutputformat(mediarecorder.outputformat.mpeg_4); recorder.setaudioencoder(mediarecorder.audioencoder.aac); } else { // older version of android, use crappy sounding voice codec recorder.setaudiosamplingrate(8000); recorder.setaudioencodingbitrate(12200); recorder.setoutputformat(mediarecorder.outputformat.three_gpp); recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb); } recorder.setoutputfile(file.getabsolutepath()); try { recorder.prepare(); } catch (ioexception e) { throw new runtimeexception(e); }
it seems devices sdk lower 10 cannot record quality.
Comments
Post a Comment