我正在尝试按照this样本实施视频捕获应用。
我可以更改ISO值,更新我的预览并使用该值制作视频,但我也想让我的用户在录制时更改ISO值而不会中断视频,但我无法找到如何。
这是我用来开始录制的代码:
private void startRecording() {
final Camera2Controller me = this;
try {
this.mediaRecorder = this.prepareMediaRecorder(); // Nothing special about it
final CaptureRequest.Builder requestBuilder = this.getCameraDevice().createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
this.updateRequestForCapture(requestBuilder);
ArrayList<Surface> surfaces = new ArrayList<>();
surfaces.add(this.surfaceHolder.getSurface());
surfaces.add(this.mediaRecorder.getSurface());
for (Surface target : surfaces) {
requestBuilder.addTarget(target);
}
this.captureRequest = requestBuilder.build();
this.getCameraDevice().createCaptureSession(surfaces, new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(@NonNull CameraCaptureSession session) {
try {
me.setCaptureSession(session);
session.setRepeatingRequest(me.captureRequest, null, null);
me.mediaRecorder.start();
me._isRecording = true;
}
catch (Exception e) {
try {
me._isRecording = false;
me.getCaptureSession().stopRepeating();
me.getCaptureSession().abortCaptures();
me.getCaptureSession().close();
}
catch (CameraAccessException cae) {
cae.printStackTrace();
}
finally {
me.mediaRecorder.reset();
me.mediaRecorder.release();
me.mediaRecorder = null;
}
}
}
@Override
public void onConfigureFailed(@NonNull CameraCaptureSession session) {
me._isRecording = false;
}
}, this);
}
catch (CameraAccessException e) {
me._isRecording = false;
}
}
public void updateRequestForCapture(CaptureRequest.Builder requestBuilder) {
requestBuilder.set(CaptureRequest.CONTROL_MODE, this.ControlMode);
requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, this.AEMode);
requestBuilder.set(CaptureRequest.CONTROL_AWB_LOCK, this.WhiteBalanceLock);
requestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, this.ISO);
requestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, this.ExposureTime);
requestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, this.WhiteBalanceMode);
requestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, this.SceneMode);
requestBuilder.set(CaptureRequest.CONTROL_AF_MODE, this.AFMode);
requestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, this.AFTrigger);
requestBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, this.ColorCorrectionMode);
requestBuilder.set(CaptureRequest.COLOR_CORRECTION_TRANSFORM, this.ColorSpaceTransform);
requestBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, this.ColorCorrectionGain);
}
有谁能建议我如何解决这个问题?