简体   繁体   English

Android:同时录制原始音频和录制视频

[英]Android: Record raw audio and record video at the same time

I develop an Android app based on sound and video records. 我开发了一个基于声音和视频记录的Android应用程序。 I would like to get a real-time playback of the mic audio in the headphones while previewing AND capturing the video and sound. 我想在预览和捕获视频和声音的同时在耳机中实时播放麦克风音频。

What i have now, working fine alone: 我现在拥有的,独自工作:

1) use Superpowered library to record audio and playing it back in real-time (during preview and record). 1)使用Superpowered库来录制音频并实时播放(在预览和录制期间)。 Behind the scene, it does directly with C++ the work of AudioRecord by pushing the buffer to the output (headphones). 在幕后,它通过将缓冲区推送到输出(耳机),直接用C ++完成AudioRecord的工作。 The goal is to apply audio effects on the raw sound in real-time. 目标是实时对原始声音应用音频效果。

2) capture the video with mediaRecorder 2)使用mediaRecorder捕获视频

When audio playback is running, I try to launch the video record, it crashes starting : 当音频播放正在运行时,我尝试启动视频记录,它崩溃了:

E/MediaRecorder: start failed: -2147483648

I imagine that i can't launch two recording process at the same time. 我想我无法同时启动两个录制过程。 I think using the AudioRecord or Superpowered lib is the good way to process the raw audio, but I can't figure out how to record video without conflicting with the current audio recording. 我认为使用AudioRecord或Superpowered lib是处理原始音频的好方法,但我无法弄清楚如何在不与当前录音冲突的情况下录制视频。

So is there a way to achieve my feature? 那么有没有办法实现我的功能?

(minSdk 16) (minSdk 16)

According bigflake 根据bigflake

The MediaCodec class first became available in Android 4.1 (API 16). MediaCodec类首次在Android 4.1(API 16)中提供。 It was added to allow direct access to the media codecs on the device. 添加它是为了允许直接访问设备上的媒体编解码器。

In Android 4.3 (API 18), MediaCodec was expanded to include a way to provide input through a Surface (via the createInputSurface method). 在Android 4.3(API 18)中,MediaCodec进行了扩展,包括一种通过Surface提供输入的方法(通过createInputSurface方法)。 This allows input to come from camera preview or OpenGL ES rendering. 这允许输入来自相机预览或OpenGL ES渲染。

So if it's possible please think about increasing MinSDK to 18 and use AudioVideoRecordingSample or HWEncoderExperiments as examples. 因此,如果可能,请考虑将MinSDK增加到18并使用AudioVideoRecordingSampleHWEncoderExperiments作为示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM