【发布时间】:2013-11-17 10:16:27
【问题描述】:
我正在尝试使用 MediaRecorder 对象以我的设备三星 S2 上可用的最高质量录制视频。但是,使用我当前的代码,我在调用 MediaRecorder.close() 时看到挂起,然后手机崩溃(LOGCAT:http://pastebin.com/yzqWqta3)
当 CamcorderProfile 设置为 QUALITY_LOW 时,我有一段工作代码,但同样的代码会导致设备崩溃(需要重新启动才能恢复),Camcorder Profile 更改为 QUALITY_HIGH。
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
之后设置为记录器对象;
recorder.setProfile(camcorderProfile);
但是,在调用 MediaRecorder.stop() 之后,以下内容会导致崩溃;
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
我的代码基于这个项目(来自 Android Pro Media 人 - Shawn van Every)https://github.com/vanevery/Custom-Video-Capture-with-Preview.git
原始形式的代码也会导致记录器在Mediarecorder#start() 上崩溃(LOGCAT:http://pastebin.com/L2ahkj82),我不得不使用此线程中的建议来应用三星特定的修复;
“ [Q] 无法在 Galaxy Sii 上录制高清视频”;
http://forum.xda-developers.com/showthread.php?t=1104970&page=8
Camera.Parameters p = camera.getParameters();
// http://forum.xda-developers.com/showthread.php?t=1104970&page=8
p.set( "cam_mode", 1 ); // green mess in video file without this
p.setFocusMode(Parameters.FOCUS_MODE_AUTO); // works
p.setPreviewSize(camcorderProfile.videoFrameWidth, camcorderProfile.videoFrameHeight);
p.setPreviewFrameRate(camcorderProfile.videoFrameRate);
camera.setParameters(p);
camera.setDisplayOrientation(0);
camera.setPreviewDisplay(holder);
camera.startPreview();
但是,使用上面的代码,我要么崩溃,要么应用停止响应; LOGCAThttp://pastebin.com/D7Ap7yQZ
检查设备对 1920/1080 或 QUALITY_HIGH 的支持情况
股票相机应用程序支持以 1920x1080 的分辨率录制,它称之为“超精细”,但分辨率是明确设置的,我猜想适当的参数是从已知的良好设置推断出来的,而不是从 QUALITY_HIGH CamcorderProfile 推断出来的。
但是,在 Play 商店中有 other apps 支持 1920x1080,可以在 S2 上运行来自 3rd 方(他们可能无法访问三星专有文档),因此应该可以通过设置每个来复制 QUALITY_HIGH显式参数化,或揭开三星未记录的 bf*ckery。
设备自检
三星 SII 似乎支持使用 QUALITY_HIGH;
Log.v(LOGTAG, "has Profile QUALITY HIGH? : "+
CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_HIGH));
返回这个;
V/VIDEOCAPTURE( 7897): has Profile QUALITY HIGH? : true
并且 Android 文档指出“QUALITY_HIGH”是一个预定义的配置文件,表示对应于最高可用分辨率的级别。
int QUALITY_HIGH Quality level corresponding to the highest available resolution.
http://developer.android.com/reference/android/media/CamcorderProfile.html#QUALITY_HIGH
注意事项
- 我今天早上将手机恢复出厂设置
- 我尝试了其他 SD 卡,但在同一个地方遇到了同样的崩溃
- 这可能是硬件问题。我还没有找到另一台三星 S2 进行测试。
相关的 SO 问题
还有其他关于在三星 S2 上录制高质量视频的 SO 问题,但没有一个答案,所以我创建了这个问题来捕获我的日志和代码
"Video recorded with Android MediaRecorder is corrupted on Samsung Galaxy S2"
Samsung Galaxy SIII mediaRecorder() issues. (Corrupt Video)
可能的解决方案
这个 SO question and answer 似乎解决了同样的问题,但我无法使用给出的代码示例复制他们的结果; CamcorderProfile.QUALITY_HIGH resolution produces green flickering video
有一个thread on xda的链接,里面有一些详细的分析
【问题讨论】:
标签: android samsung-mobile mediarecorder android-mediarecorder