【发布时间】:2018-07-08 17:15:00
【问题描述】:
我正在尝试捕捉 Android 设备屏幕的视频,但在某些三星设备上,我得到的视频被粉红色的失真覆盖覆盖。
查看以下三星 DOUS 和 Pixel XL 上的输出视频截图:
三星 DUOS G532F(API 23) - Pixel XL 2 (API 27)
这是我设置媒体记录器的方法
MediaRecorder recorder = new MediaRecorder();
recorder.setVideoSource(SURFACE);
recorder.setOutputFormat(MPEG_4);
recorder.setVideoFrameRate(recordingInfo.frameRate);
recorder.setVideoEncoder(H264);
recorder.setVideoSize(recordingInfo.width, recordingInfo.height);
recorder.setVideoEncodingBitRate(3 * 1000 * 1000);
recordingInfo中使用的默认值
private static final int DEFAULT_VIDEO_WIDTH = 540;
private static final int DEFAULT_VIDEO_HEIGHT = 960;
private static final int DEFAULT_VIDEO_FRAMERATE = 30;
camcorderProfile.videoFrameWidth = DEFAULT_VIDEO_WIDTH;
camcorderProfile.videoFrameHeight = DEFAULT_VIDEO_HEIGHT;
camcorderProfile.videoFrameRate = DEFAULT_VIDEO_FRAMERATE;
还有CamcorderProfile
CamcorderProfile camcorderProfile;
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_TIME_LAPSE_QVGA)) {
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_QVGA);
} else {
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
}
我也尝试了CamcorderProfile.QUALITY_HIGH 和其他一些配置文件,结果相同
【问题讨论】:
-
仅使用您的应用程序会发生这种情况吗? - 您是否在该设备上尝试过另一个屏幕录像机? - 因为很有可能是硬件问题。
-
是的,我做到了,其他录音应用程序在此设备上运行良好
-
你尝试改变你的比特率吗?也许像
setVideoEncodingBitRate(512 * 1000) -
我也建议你看看:medium.com/jamesob-com/…
-
@AmrBarakat 我遇到了同样的问题,它也发生在我的三星设备上(同样的问题,你描述的粉红色掩盖了视频,有时是绿色).....你能分享一下吗如果你解决了这个问题,解决方案。
标签: android android-mediaprojection