我有一些奇怪的问题,而且找不到答案。我使用wowza进行直播。它使用AudioRecord recorder = new AudioRecord(this.mAudioSource, ... )
内部,mAudioSource
默认= 5(像MediaRecorder.AudioSource.CAMCORDER
)它工作得很好,但同时我需要录制带有更多视频质量的设备内存中的音频视频。
对于内部记录,我使用MediaRecorder。
mWZCameraView.getCamera().getPlatformDevice().unlock();
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setCamera(mWZCameraView.getCamera().getPlatformDevice());
//mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setVideoEncodingBitRate(15000000);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(1920, 1080);
try {
mMediaRecorder.prepare();
} catch (Exception e) {
// This is thrown if the previous calls are not called with the
// proper order
e.printStackTrace();
} finally {
mMediaRecorder.start();
}
正如您在评论中看到的setAudioSource
,在这种情况下,实时视频获取设备上的音频和视频不会获得音频。如果打开setAudioSource
和setAudioEncoder
我的实时视频将没有录音和带音频的设备。
我尝试了AudioSource和AudioEncoder的不同组合,但它总是在其中一个视频中录制音频。
如果可以并行使用CAMCORDER,我找不到答案。
PS。我知道在另一个文件中通过字节录制音频的选项并在之后合并它,但它不是那么容易,我会尝试最后一个选项。
似乎我找到了答案,也许这会对某人有所帮助。这里写的答案是:https://stackoverflow.com/a/12935309/7917629,“Android设备基于将开放音频输入流的数量限制为1”。
Wowza在audioRecorder中用来获取音频,看起来当我添加到mediaRecorder setAudioSource
时它也尝试使用audioRecorder。所以该选项设置回调到像mWZAudioDevice.registerAudioSampleListener(new WZAudioDevice.AudioSampleListener())
这样的wowza来从audioRecord获取byte []。