Search code examples
androidvideocrashrecordingautofocus

Android: record video with "continuous" auto-focus


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):

camera = Camera.open();
camera.setPreviewDisplay(holder);

Parameters parameters = camera.getParameters();

then I do either

parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);

or

parameters.set("focus-mode", "continuous-video");

both should do the same thing; then I set parameters with

camera.setParameters(parameters);

This last line always crashes! So do I miss something?

By the way, I test on rather new devices like Desire HD, Galaxy S, Galaxy Tab 7 and 10.1, which must have support for continuous auto-focus; at least their built-in camera apps support it.


Solution

  • 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.