LG G3 上的相机设置参数失败

camera setParameters failed on LG G3

我正在为相机设置参数,以准备在 Android 应用中进行视频录制。 此代码片段似乎适用于多种设备,但在 LG G3:

上会崩溃
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:1852)

有谁知道这些参数之一是否对该设备有害?

 p = myCamera.getParameters();
        surfaceHolder = mSurfaceView.getHolder();
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        p.setPictureSize(cam_width, cam_height);

        if (myCamera != null) {
            try {
                myCamera.setPreviewDisplay(surfaceHolder);
                List<String> focusModes = p.getSupportedFocusModes();   
                if (focusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
                    p.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); 
                p.setPreviewSize(cam_width, cam_height);
                int[] max = VideoQuality.determineMaximumSupportedFramerate(p);
                p.setPreviewFpsRange(max[0], max[1]);
                p.setRecordingHint(true);
                if(myCamera != null)
                myCamera.setParameters(p); 

cam_width&cam_height是这样计算的:

 camprev = p.getSupportedPreviewSizes();
 int high_width_preview = myCamera.getParameters().getSupportedPreviewSizes().get(0).width;
 int high_height_preview = myCamera.getParameters().getSupportedPreviewSizes().get(0).height;
 for(int i =0; i< myCamera.getParameters().getSupportedPreviewSizes().size(); i++){
     Size sizet = myCamera.getParameters().getSupportedPreviewSizes().get(i);
     Log.d("TAGME_NEXT", "supported preview sizeS: " + sizet.width + " " + sizet.height);
     if(sizet.width > high_width_preview) {
     high_width_preview = sizet.width;
     high_height_preview = sizet.height;
     }
 }

 cam_width = high_width_preview;
 cam_height = high_height_preview;

已解决删除问题:

p.setPictureSize(cam_width, cam_height);