diff --git a/README.md b/README.md index 14ef6f9f..2f4a5316 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ Using CameraView is extremely simple: app:cameraGestureScrollVertical="none|zoom|exposureCorrection|filterControl1|filterControl2" app:cameraEngine="camera1|camera2" app:cameraPreview="glSurface|surface|texture" + app:cameraPreviewFrameRate="@integer/preview_frame_rate" app:cameraFacing="back|front" app:cameraHdr="on|off" app:cameraFlash="on|auto|torch|off" diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index 27704ff0..3921abe6 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -1450,8 +1450,12 @@ public class CameraView extends FrameLayout implements LifecycleObserver { } /** - * Sets the frame rate for the video - * Will be used by {@link #takeVideoSnapshot(File)}. + * Sets the preview frame rate in frames per second. + * This rate will be used, for example, by the frame processor and in video + * snapshot taken through {@link #takeVideo(File)}. + * + * A value of 0F will restore the rate to a default value. + * * @param frameRate desired frame rate */ public void setPreviewFrameRate(float frameRate) { @@ -1459,7 +1463,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver { } /** - * Returns the current frame rate. + * Returns the current preview frame rate. + * This can return 0F if no frame rate was set. + * + * @see #setPreviewFrameRate(float) * @return current frame rate */ public float getPreviewFrameRate() { diff --git a/docs/_posts/2018-12-20-controls.md b/docs/_posts/2018-12-20-controls.md index cf89d708..281d4e85 100644 --- a/docs/_posts/2018-12-20-controls.md +++ b/docs/_posts/2018-12-20-controls.md @@ -30,7 +30,8 @@ or `CameraOptions.supports(Control)` to see if it is supported. app:cameraVideoCodec="deviceDefault|h263|h264" app:cameraVideoMaxSize="0" app:cameraVideoMaxDuration="0" - app:cameraVideoBitRate="0"/> + app:cameraVideoBitRate="0" + app:cameraPreviewFrameRate="30"/> ``` ### APIs @@ -40,6 +41,8 @@ or `CameraOptions.supports(Control)` to see if it is supported. Which camera to use, either back facing or front facing. Defaults to the first available value (tries `BACK` first). +The available values are exposed through the `CameraOptions` object. + ```java cameraView.setFacing(Facing.BACK); cameraView.setFacing(Facing.FRONT); @@ -49,6 +52,8 @@ cameraView.setFacing(Facing.FRONT); Flash mode, either off, on, auto or torch. Defaults to `OFF`. +The available values are exposed through the `CameraOptions` object. + ```java cameraView.setFlash(Flash.OFF); cameraView.setFlash(Flash.ON); @@ -61,6 +66,8 @@ cameraView.setFlash(Flash.TORCH); Sets the encoder for video recordings. Defaults to `DEVICE_DEFAULT`, which should typically be H_264. +The available values are exposed through the `CameraOptions` object. + ```java cameraView.setVideoCodec(VideoCodec.DEVICE_DEFAULT); cameraView.setVideoCodec(VideoCodec.H_263); @@ -72,6 +79,8 @@ cameraView.setVideoCodec(VideoCodec.H_264); Sets the desired white balance for the current session. Defaults to `AUTO`. +The available values are exposed through the `CameraOptions` object. + ```java cameraView.setWhiteBalance(WhiteBalance.AUTO); cameraView.setWhiteBalance(WhiteBalance.INCANDESCENT); @@ -84,6 +93,8 @@ cameraView.setWhiteBalance(WhiteBalance.CLOUDY); Turns on or off HDR captures. Defaults to `OFF`. +The available values are exposed through the `CameraOptions` object. + ```java cameraView.setHdr(Hdr.OFF); cameraView.setHdr(Hdr.ON); @@ -94,6 +105,8 @@ cameraView.setHdr(Hdr.ON); Turns on or off audio stream while recording videos. Defaults to `ON`. +The available values are exposed through the `CameraOptions` object. + ```java cameraView.setAudio(Audio.OFF); cameraView.setAudio(Audio.ON); // on but depends on video config @@ -143,6 +156,27 @@ cameraView.setVideoBitRate(0); cameraView.setVideoBitRate(4000000); ``` +##### cameraPreviewFrameRate + +Controls the preview frame rate, in frames per second. +Use a value of 0F to restore the camera default value. + +```java +cameraView.setPreviewFrameRate(30F); +cameraView.setPreviewFrameRate(0F); +``` + +The preview frame rate is an important parameter because it will also +control (broadly) the rate at which frame processor frames are dispatched, +the video snapshots frame rate, and the rate at which real-time filters are invoked. + +The available values are exposed through the `CameraOptions` object: + +```java +float min = options.getPreviewFrameRateMinValue(); +float max = options.getPreviewFrameRateMaxValue(); +``` + ### Zoom There are two ways to control the zoom value: