Android: record video with “continuous” auto-focus

前端 未结 2 1812
挽巷
挽巷 2021-02-03 14:39

I work on video recording; everything works except for requesting continuous focus. This is what I do (tried both in surfaceCreated and surfaceChanged with no success):

相关标签:
2条回答
  • 2021-02-03 15:00

    Ok, I have sort of solution to this problem: I was able to manually focus camera calling Camera#autoFocus(...).

    This still has serious issues. First, calling autofocus while shooting video is not working on some Samsung devices. Also it's not a good idea to force your users to manually focus the camera during video recording.

    So if you were able to normally focus your videos while recording - your advice would be very helpful.

    0 讨论(0)
  • 2021-02-03 15:04

    You should check if Continuous Auto Focus is supported by the device. This is something that works for me, please give it a try.

    boolean startContinuousAutoFocus() {
    
        Camera.Parameters params = mCamera.getParameters();
    
        List<String> focusModes = params.getSupportedFocusModes();
    
        String CAF_PICTURE = Parameters.FOCUS_MODE_CONTINUOUS_PICTURE, 
               CAF_VIDEO = Parameters.FOCUS_MODE_CONTINUOUS_VIDEO, 
               supportedMode = focusModes
                       .contains(CAF_PICTURE) ? CAF_PICTURE : focusModes
                       .contains(CAF_VIDEO) ? CAF_VIDEO : "";
    
        if (!supportedMode.equals("")) {
    
            params.setFocusMode(supportedMode);
            mCamera.setParameters(params);
            return true;
        }
    
        return false;
    }
    
    0 讨论(0)
提交回复
热议问题