是否可以录制音频通过Android模拟器? [英] Is It Possible to Record Audio Through Android Emulator?

查看:885
本文介绍了是否可以录制音频通过Android模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个医疗项目和应用程序可以能够记录医生和病人之间的对话和转录发送。

I am Working On a Medical Project and the app can able to record the conversation between doctor and patient and send it for Transcription.

分配:基本程序是录制和播放录制的音频
问题:当过录音开始时,它会记录10-20秒LogCat中显示后:

Assignment : Basically App is for Recording and Playing the recorded audio.
Problem : When ever recording starts, it records 10-20 seconds after that LogCat Shows:

05-07 11:42:52.502: W/MediaProfiles(6321): could not find media config xml file
05-07 11:42:52.522: I/MPEG4Writer(6321): limits: 2147483647/0 bytes/us, bit rate: 12200 bps and the estimated moov size 3072 bytes
05-07 11:42:52.532: E/AudioFlinger(6321): Error reading audio input
05-07 11:42:58.432: W/AudioRecord(6321): obtainBuffer timed out (is the CPU pegged?) user=00000000, server=00000000
05-07 11:42:58.432: E/AudioFlinger(6321): Error reading audio input
05-07 11:43:03.403: W/AudioRecord(6321): obtainBuffer timed out (is the CPU pegged?) user=00000000, server=00000000
05-07 11:43:03.403: E/AudioFlinger(6321): Error reading audio input
05-07 11:43:03.403: A/AudioSource(6321): frameworks/base/media/libstagefright/AudioSource.cpp:327 timestampUs > mPrevSampleTimeUs
05-07 11:43:03.612: I/DEBUG(31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-07 11:43:03.612: I/DEBUG(31): Build fingerprint: 'generic/sdk/generic:2.3.3/GRI34/101070:eng/test-keys'
05-07 11:43:03.612: I/DEBUG(31): pid: 6321, tid: 6442  >>> /system/bin/mediaserver <<<
05-07 11:43:03.612: I/DEBUG(31): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
05-07 11:43:03.622: I/DEBUG(31):  r0 deadbaad  r1 0000fef8  r2 00000027  r3 00000000
05-07 11:43:03.632: I/DEBUG(31):  r4 00000080  r5 afd46668  r6 40806d78  r7 40806d7c
05-07 11:43:03.632: I/DEBUG(31):  r8 a2f51fa1  r9 0000fd28  10 00100000  fp 00000001
05-07 11:43:03.632: I/DEBUG(31):  ip ffffffff  sp 408068e0  lr afd19d8f  pc afd15ef0  cpsr 00000030
05-07 11:43:03.922: I/DEBUG(31):          #00  pc 00015ef0  /system/lib/libc.so
05-07 11:43:03.922: I/DEBUG(31):          #01  pc 00001440  /system/lib/liblog.so
05-07 11:43:03.922: I/DEBUG(31): code around pc:
05-07 11:43:03.932: I/DEBUG(31): afd15ed0 68241c23 d1fb2c00 68dae027 d0042a00 
05-07 11:43:03.932: I/DEBUG(31): afd15ee0 20014d18 6028447d 48174790 24802227 
05-07 11:43:03.932: I/DEBUG(31): afd15ef0 f7f57002 2106eb56 ec92f7f6 0563aa01 
05-07 11:43:03.932: I/DEBUG(31): afd15f00 60932100 91016051 1c112006 e818f7f6 
05-07 11:43:03.932: I/DEBUG(31): afd15f10 2200a905 f7f62002 f7f5e824 2106eb42 
05-07 11:43:03.942: I/DEBUG(31): code around lr:
05-07 11:43:03.942: I/DEBUG(31): afd19d6c 230ed505 21005ec0 f7f12202 89a2ebec 
05-07 11:43:03.942: I/DEBUG(31): afd19d7c 1c294804 81a04010 5ea0220e f7f11c32 
05-07 11:43:03.942: I/DEBUG(31): afd19d8c bd70eb72 ffffefff 1c04b510 5ec0230e 
05-07 11:43:03.942: I/DEBUG(31): afd19d9c eb58f7f1 db032800 180b6d21 e0036523 
05-07 11:43:03.952: I/DEBUG(31): afd19dac 4b0289a2 81a34013 46c0bd10 ffffefff 
05-07 11:43:03.952: I/DEBUG(31): stack:
05-07 11:43:03.952: I/DEBUG(31):     408068a0  00000008  
05-07 11:43:03.952: I/DEBUG(31):     408068a4  afd18407  /system/lib/libc.so
05-07 11:43:03.952: I/DEBUG(31):     408068a8  afd42604  /system/lib/libc.so
05-07 11:43:03.952: I/DEBUG(31):     408068ac  afd46784  
05-07 11:43:03.952: I/DEBUG(31):     408068b0  00000000  
05-07 11:43:03.952: I/DEBUG(31):     408068b4  afd19375  /system/lib/libc.so
05-07 11:43:03.952: I/DEBUG(31):     408068b8  00000009  
05-07 11:43:03.963: I/DEBUG(31):     408068bc  afd183d9  /system/lib/libc.so
05-07 11:43:03.963: I/DEBUG(31):     408068c0  afa01199  /system/lib/liblog.so
05-07 11:43:03.963: I/DEBUG(31):     408068c4  00000000  
05-07 11:43:03.963: I/DEBUG(31):     408068c8  afd46668  
05-07 11:43:03.963: I/DEBUG(31):     408068cc  40806d78  
05-07 11:43:03.963: I/DEBUG(31):     408068d0  40806d7c  
05-07 11:43:03.963: I/DEBUG(31):     408068d4  afd18677  /system/lib/libc.so
05-07 11:43:03.963: I/DEBUG(31):     408068d8  df002777  
05-07 11:43:03.963: I/DEBUG(31):     408068dc  e3a070ad  
05-07 11:43:03.963: I/DEBUG(31): #00 408068e0  408068dc  
05-07 11:43:03.963: I/DEBUG(31):     408068e4  00000001  
05-07 11:43:03.972: I/DEBUG(31):     408068e8  a303abbe  /system/lib/libstagefright.so
05-07 11:43:03.972: I/DEBUG(31):     408068ec  0000000c  
05-07 11:43:03.972: I/DEBUG(31):     408068f0  40806914  
05-07 11:43:03.972: I/DEBUG(31):     408068f4  fffffbdf  
05-07 11:43:03.972: I/DEBUG(31):     408068f8  00000001  
05-07 11:43:03.972: I/DEBUG(31):     408068fc  40806914  
05-07 11:43:03.972: I/DEBUG(31):     40806900  a303abbe  /system/lib/libstagefright.so
05-07 11:43:03.972: I/DEBUG(31):     40806904  afa01443  /system/lib/liblog.so
05-07 11:43:03.983: I/DEBUG(31): #01 40806908  40806914  
05-07 11:43:03.983: I/DEBUG(31):     4080690c  afa01443  /system/lib/liblog.so
05-07 11:43:03.983: I/DEBUG(31):     40806910  40806d2c  
05-07 11:43:03.983: I/DEBUG(31):     40806914  6d617266  
05-07 11:43:03.983: I/DEBUG(31):     40806918  726f7765  
05-07 11:43:03.983: I/DEBUG(31):     4080691c  622f736b  
05-07 11:43:03.983: I/DEBUG(31):     40806920  2f657361  
05-07 11:43:03.983: I/DEBUG(31):     40806924  6964656d  
05-07 11:43:03.983: I/DEBUG(31):     40806928  696c2f61  
05-07 11:43:03.983: I/DEBUG(31):     4080692c  61747362  
05-07 11:43:03.983: I/DEBUG(31):     40806930  72666567  
05-07 11:43:03.983: I/DEBUG(31):     40806934  74686769  
05-07 11:43:03.992: I/DEBUG(31):     40806938  6475412f  
05-07 11:43:03.992: I/DEBUG(31):     4080693c  6f536f69  
05-07 11:43:03.992: I/DEBUG(31):     40806940  65637275  
05-07 11:43:03.992: I/DEBUG(31):     40806944  7070632e  
05-07 11:43:03.992: I/DEBUG(31):     40806948  3732333a  
05-07 11:43:03.992: I/DEBUG(31):     4080694c  6d697420  
05-07 11:43:05.342: I/BootReceiver(61): Copying /data/tombstones/tombstone_03 to DropBox (SYSTEM_TOMBSTONE)
05-07 11:43:05.372: W/IMediaDeathNotifier(386): media server died
05-07 11:43:05.372: I/ServiceManager(28): service 'media.audio_flinger' died
05-07 11:43:05.372: I/ServiceManager(28): service 'media.audio_policy' died
05-07 11:43:05.372: I/ServiceManager(28): service 'media.player' died
05-07 11:43:05.372: I/ServiceManager(28): service 'media.camera' died
05-07 11:43:05.382: W/AudioSystem(61): AudioFlinger server died!
05-07 11:43:05.382: W/AudioSystem(61): AudioPolicyService server died!
05-07 11:43:05.632: D/dalvikvm(61): GC_CONCURRENT freed 1046K, 47% free 4504K/8391K, external 3520K/3903K, paused 8ms+19ms
05-07 11:43:06.072: I/(6479): ServiceManager: 0xad50
05-07 11:43:06.072: D/AudioHardwareInterface(6479): setMode(NORMAL)
05-07 11:43:06.072: I/CameraService(6479): CameraService started (pid=6479)
05-07 11:43:06.082: I/AudioFlinger(6479): AudioFlinger's thread 0xc658 ready to run
05-07 11:43:06.908: E/AudioService(61): Media server died.
05-07 11:43:06.912: E/AudioService(61): Media server started.
05-07 11:43:06.922: D/AudioHardwareInterface(6479): setMode(NORMAL)
05-07 11:43:06.922: W/AudioPolicyManagerBase(6479): setPhoneState() setting same state 0

code:

protected String doInBackground(MediaRecorder... params) {
            mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
            mFileName += "/_audioDirectory/" time +"/"+f_Name+ ".mp3";
            mRecorder = new MediaRecorder();
            mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
            mRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
            mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
            mRecorder.setOutputFile(mFileName);

            try {
                mRecorder.prepare();
            } catch (Exception e) {
                Log.e(LOG_TAG, e.toString());
            }
            mRecorder.start();
            Log.i("recording starts", "now");
            return "success";
        }

我通过的Andr​​oid文档消失,其明确提及MediaRecorder不在emulator.Right工作,现在我没有android手机进行测试。

I gone through Android Documentation and its clearly mention MediaRecorder does not work on the emulator.Right Now i dont have android phone to test.

也: <一href="http://stackoverflow.com/questions/5254994/can-the-android-emulator-record-and-play-back-audio-using-pc-hardware">Here <一href="http://stackoverflow.com/questions/7953840/can-not-use-mediarecorder-on-android-emulator-is-the-storage-location-wrong?lq=1">Here 这里

推荐答案

录制音频可能至少在标准的 2.3.3 仿真器在Windows 7;我已经尝试过了,它的工作原理。但是,录制的音频没有在我的案件听起来有点怪(慢)。我没有调查的原因。

Recording audio is possible at least in the standard 2.3.3 emulator on Windows 7; I have tried it and it works. However, the recorded audio did sound a bit weird (slow) in my case. I did not investigate the cause.

您需要录音+播放支持添加到该仿真器(Android SDK和AVD管理器 - >虚拟设备 - >编辑 - >硬件 - >新建)。然后用[MediaRecorder API] [1]录制(MediaRecorder.AudioSource.MIC)。

code是:

fMediaRecorder= new MediaRecorder();
fMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
fMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
fMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

fMediaRecorder.setAudioChannels(1);
fMediaRecorder.setAudioSamplingRate(8000);

fMediaRecorder.setOutputFile(fTmpFile.getAbsolutePath());

fMediaRecorder.prepare();

fMediaRecorder.start();

您还需要

&LT;使用-权限的Andr​​oid:名称=android.permission.RECORD_AUDIO/>

< uses-permission android:name="android.permission.RECORD_AUDIO"/>

在你的Andr​​oidManifest.xml中。

in your AndroidManifest.xml.

对我的作品,但音频失真。

Works for me, but Audio IS distorted.

这篇关于是否可以录制音频通过Android模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆