android ktv 开发过程5-android调用ffmpeg成功

mMediaPlayer.prepare(); Log.v(TAG,"==mRecordPath==="+mRecordPath+"=mAccompanyPath=="+mAccompanyPath); mAccompany = new FileInputStream(mAccompanyPath); mRecord = new FileOutputStream(mRecordPath); mAccompany.read(header); // mRecord.write(header); mMediaPlayer.start(); mAudioRecord.startRecording(); mUpdateProgressHandler.post(mUpdateProgressRunnable); // 边录音边混合 while (isRunning) { Log.v("H3c", "run=============================================="); int rSize = mAudioRecord.read(recordBuf, 0, RecorderParameter.bufferSizeInBytes); Log.v("H3c", "go:" + rSize); int size = mAccompany.read(accompanyBuf, 0, RecorderParameter.bufferSizeInBytes); Log.v("H3c", "s:" + size); if (size < 0) { isRunning = false; Log.v("H3c", "run======isRunning======="+isRunning); continue; } byte[] mixBuff = new byte[size]; //播放一包录音 if(null != audioTrack){ audioTrack.write(recordBuf, 0, rSize); } for (int i = 0; i < size; i++) { mixBuff[i] = (byte) Math .round((accompanyBuf[i] + recordBuf[i]) / 2); } mRecord.write(mixBuff); } } catch (IOException e) { Log.v("H3c", "=====catch==="+e); e.printStackTrace(); } finally { Log.v("H3c", "=====final====="+isRunning); if (mMediaPlayer != null) { mMediaPlayer.stop(); } if (mAudioRecord != null) { mAudioRecord.stop(); } if(null != audioTrack){ audioTrack.stop(); } try { mAccompany.close(); mRecord.close(); } catch (IOException e) { e.printStackTrace(); } mUpdateProgressHandler .removeCallbacks(mUpdateProgressRunnable); // RemoveFile(mRecordPath); } copyWaveFile(mRecordPath, SavaAudioPath); RemoveFile(mRecordPath); Log.e("H3c", "end");
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值