android - 带有内部音频的 Android 屏幕录像机
问题描述
我正在尝试使用Mediaprojection
and记录 android 手机屏幕Media Recorder
。我可以使用麦克风录制屏幕和音频。下面是我的代码。
private void initRecorder() {
try {
File backupPath = Environment.getExternalStorageDirectory();
backupPath = new File(backupPath.getPath()+"/VideoRecording");
if (!backupPath.exists()) {
backupPath.mkdirs();
}
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mMediaRecorder.setOutputFile(backupPath.getPath() + getFormattedDate()+".mp4");
mMediaRecorder.setVideoSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncodingBitRate(1500 * 1500);
mMediaRecorder.setVideoFrameRate(30);
int rotation = getWindowManager().getDefaultDisplay().getRotation();
int orientation = ORIENTATIONS.get(rotation + 90);
mMediaRecorder.setOrientationHint(orientation);
mMediaRecorder.prepare();
} catch (IOException e) {
e.printStackTrace();
}
}
我的查询:
如何仅记录来自移动设备的音频结果。如果我通过麦克风录音,周围的噪音也会被录音。我需要跳过外部噪音,只记录手机的音频。
录制的视频大小以手机屏幕分辨率为准。如何录制不同纵横比的屏幕,如 16:9?
解决方案
推荐阅读
- c# - 请求在 IIS 上停留在 BeginRequest 状态
- java - Grizzly 2.4 Embedded Https Server 在 NEED_WRAP 上无限循环
- javascript - 如何在 GEE 中使用 shapefile 资产作为 AOI?
- c# - 无法修复 SonarCloud 上的 SQL 注入
- reactjs - 删除行时更新单元格背景颜色。(反应表)
- c# - 无法使用 C# 的 selenium Web 驱动程序根据标签名称选择元素
- javascript - 如何以天、小时和分钟显示下一个生日倒计时?
- haskell - Haskell 中真正的非确定性
- python-3.x - 将相似键的字典转换为字典列表(更新)
- java - 如何在 Java 中为 Koin 获取 Android 上下文