本文主要是介绍安卓camera2报错打不开,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
author | daisy.skye的博客_CSDN博客-嵌入式,Qt,Linux领域博主 daisy.skye_嵌入式,Linux,Qt-CSDN博客daisy.skye擅长嵌入式,Linux,Qt,等方面的知识https://blog.csdn.net/qq_40715266?type=blog |
查看日志报错,原因是找不到对应的分辨率
MediaProfiles: The given camcorder profile camera 2 quality 1 is not found
E MediaProfiles: The given camcorder profile camera 2 quality 5 is not found
.h
enum camcorder_quality {
CAMCORDER_QUALITY_LIST_START = 0,
CAMCORDER_QUALITY_LOW = 0,
CAMCORDER_QUALITY_HIGH = 1,
CAMCORDER_QUALITY_QCIF = 2,
CAMCORDER_QUALITY_CIF = 3,
CAMCORDER_QUALITY_480P = 4,
CAMCORDER_QUALITY_720P = 5,
CAMCORDER_QUALITY_1080P = 6,
CAMCORDER_QUALITY_QVGA = 7,
CAMCORDER_QUALITY_2160P = 8,
CAMCORDER_QUALITY_LIST_END = 8,
.cpp
int MediaProfiles::getCamcorderProfileParamByName(const char *name,
int cameraId,
camcorder_quality quality) const
{ALOGV("getCamcorderProfileParamByName: %s for camera %d, quality %d",
name, cameraId, quality); int index = getCamcorderProfileIndex(cameraId, quality);if (index == -1) {ALOGE("The given camcorder profile camera %d quality %d is not found",
cameraId, quality);return -1;}
修改配置函数
mediaRecorder = new MediaRecorder();
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_480P));
这篇关于安卓camera2报错打不开的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!