- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在 android 项目上使用 MediaRecorder 来录制视频和音频文件。它可以正确录制,但两个文件的音量都非常低。
我用它来配置 MediaRecorder 来录制音频
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + ConfigApp.RECORDINGS_FOLDER);
if (!folder.exists())
success = folder.mkdir();
if (success) {
mFileName = folder + timeStamp + ".m4a";
currentFile = mFileName;
chrono.setBase(SystemClock.elapsedRealtime());
chrono.start();
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(TAG, "prepare() failed");
}
mRecorder.start();
handler.post(updateVisualizer);
}
当我录制视频时这是
// BEGIN_INCLUDE (configure_preview)
mCamera = CameraHelper.getDefaultCameraInstance();
// We need to make sure that our preview and recording video size are supported by the
// camera. Query camera to find all the sizes and choose the optimal size given the
// dimensions of our preview surface.
Camera.Parameters parameters = mCamera.getParameters();
List<Camera.Size> mSupportedPreviewSizes = parameters.getSupportedPreviewSizes();
Camera.Size optimalSize = CameraHelper.getOptimalPreviewSize(mSupportedPreviewSizes,
mSurfaceView.getWidth(), mSurfaceView.getHeight());
// Use the same size for recording profile.
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
profile.videoFrameWidth = optimalSize.width;
profile.videoFrameHeight = optimalSize.height;
// likewise for the camera object itself.
parameters.setPreviewSize(profile.videoFrameWidth, profile.videoFrameHeight);
mCamera.setParameters(parameters);
try {
// Requires API level 11+, For backward compatibility use {@link setPreviewDisplay}
// with {@link SurfaceView}
mCamera.setPreviewDisplay(mSurfaceView.getHolder());
mCamera.setDisplayOrientation(90);
} catch (IOException e) {
Log.e(TAG, "Surface texture is unavailable or unsuitable" + e.getMessage());
return false;
}
// END_INCLUDE (configure_preview)
// BEGIN_INCLUDE (configure_media_recorder)
mMediaRecorder = new MediaRecorder();
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
// Step 2: Set sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER );
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mMediaRecorder.setProfile(profile);
// Step 4: Set output file
String path = getVideoFile(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO).getAbsolutePath();
currentFile = path;
mMediaRecorder.setOutputFile(path);
mMediaRecorder.setOrientationHint(270);
// END_INCLUDE (configure_media_recorder)
// Step 5: Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
除了 AudioSource.CAMCORDER
之外,我还在 setAudioSource
上尝试了其他选项,但音量总是很低
我需要配置任何额外的参数吗?
最佳答案
我在使用 MediaRecorder 时遇到了同样的问题,最终找到了正确的工作解决方案。以下是您需要为高质量录音做的一些修改:
stackoverflow 上的许多解决方案建议使用
mRecorder.setAudioEncodingBitRate(16*44100);
mRecorder.setAudioSamplingRate(44100);.setAudioEncodingBiteRate(16)
,但 16 太低而不能被视为无意义。
来源:@Grant 在 stackoverflow 上的回答 very poor quality of audio recorded on my droidx using MediaRecorder, why?
关于android - MediaRecorder,录制音视频音量很低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36984853/
我们有一个运行在具有 12 GB 内存和 16 个内核的 iis 7.5 x64 (w2k8) 上的 asp.net 4.0(集成模式)Web 应用程序,该应用程序存在排队请求峰值的问题。通常队列为零
view.showFPS = true --> 显示我的游戏有 30 fps。它非常慢,我的游戏需要更高的 fps(每秒帧数)。 为什么我的游戏帧率很低,我怎样才能提高它?我注释掉了大部分代码,它的帧
我是一名优秀的程序员,十分优秀!