You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.5 KiB
139 lines
3.5 KiB
---
|
|
layout: page
|
|
title: "Controls"
|
|
subtitle: "Output parameters and capture options"
|
|
category: docs
|
|
order: 2
|
|
date: 2018-12-20 21:08:53
|
|
---
|
|
|
|
CameraView supports a wide range of controls that will control the behavior of the sensor or the
|
|
quality of the output.
|
|
|
|
Everything can be controlled through XML parameters or programmatically. For convenience, most options
|
|
are represented by `enum` classes extending the `Control` class. This makes it possible to use
|
|
`CameraView.set(Control)` to set the given control, or `CameraOptions.supports(Control)` to see if it is supported.
|
|
|
|
### XML Attributes
|
|
|
|
```xml
|
|
<com.otaliastudios.cameraview.CameraView
|
|
app:cameraFacing="front|back"
|
|
app:cameraFlash="off|on|auto|torch"
|
|
app:cameraWhiteBalance="auto|incandescent|fluorescent|daylight|cloudy"
|
|
app:cameraHdr="off|on"
|
|
app:cameraAudio="on|off"
|
|
app:cameraAudioBitRate="0"
|
|
app:cameraVideoCodec="deviceDefault|h263|h264"
|
|
app:cameraVideoMaxSize="0"
|
|
app:cameraVideoMaxDuration="0"
|
|
app:cameraVideoBitRate="0"/>
|
|
```
|
|
|
|
### APIs
|
|
|
|
##### cameraFacing
|
|
|
|
Which camera to use, either back facing or front facing.
|
|
Defaults to the first available value (tries `BACK` first).
|
|
|
|
```java
|
|
cameraView.setFacing(Facing.BACK);
|
|
cameraView.setFacing(Facing.FRONT);
|
|
```
|
|
|
|
##### cameraFlash
|
|
|
|
Flash mode, either off, on, auto or torch. Defaults to `OFF`.
|
|
|
|
```java
|
|
cameraView.setFlash(Flash.OFF);
|
|
cameraView.setFlash(Flash.ON);
|
|
cameraView.setFlash(Flash.AUTO);
|
|
cameraView.setFlash(Flash.TORCH);
|
|
```
|
|
|
|
##### cameraVideoCodec
|
|
|
|
Sets the encoder for video recordings. Defaults to `DEVICE_DEFAULT`,
|
|
which should typically be H_264.
|
|
|
|
```java
|
|
cameraView.setVideoCodec(VideoCodec.DEVICE_DEFAULT);
|
|
cameraView.setVideoCodec(VideoCodec.H_263);
|
|
cameraView.setVideoCodec(VideoCodec.H_264);
|
|
```
|
|
|
|
##### cameraWhiteBalance
|
|
|
|
Sets the desired white balance for the current session.
|
|
Defaults to `AUTO`.
|
|
|
|
```java
|
|
cameraView.setWhiteBalance(WhiteBalance.AUTO);
|
|
cameraView.setWhiteBalance(WhiteBalance.INCANDESCENT);
|
|
cameraView.setWhiteBalance(WhiteBalance.FLUORESCENT);
|
|
cameraView.setWhiteBalance(WhiteBalance.DAYLIGHT);
|
|
cameraView.setWhiteBalance(WhiteBalance.CLOUDY);
|
|
```
|
|
|
|
##### cameraHdr
|
|
|
|
Turns on or off HDR captures. Defaults to `OFF`.
|
|
|
|
```java
|
|
cameraView.setHdr(Hdr.OFF);
|
|
cameraView.setHdr(Hdr.ON);
|
|
```
|
|
|
|
##### cameraAudio
|
|
|
|
Turns on or off audio stream while recording videos.
|
|
Defaults to `ON`.
|
|
|
|
```java
|
|
cameraView.setAudio(Audio.OFF);
|
|
cameraView.setAudio(Audio.ON);
|
|
```
|
|
|
|
##### cameraAudioBitRate
|
|
|
|
Controls the audio bit rate in bits per second.
|
|
Use 0 or a negative value to fallback to the encoder default. Defaults to 0.
|
|
|
|
```java
|
|
cameraView.setAudioBitRate(0);
|
|
cameraView.setAudioBitRate(64000);
|
|
```
|
|
|
|
##### cameraVideoMaxSize
|
|
|
|
Defines the maximum size in bytes for recorded video files.
|
|
Once this size is reached, the recording will automatically stop.
|
|
Defaults to unlimited size. Use 0 or negatives to disable.
|
|
|
|
```java
|
|
cameraView.setVideoMaxSize(100000);
|
|
cameraView.setVideoMaxSize(0); // Disable
|
|
```
|
|
|
|
##### cameraVideoMaxDuration
|
|
|
|
Defines the maximum duration in milliseconds for video recordings.
|
|
Once this duration is reached, the recording will automatically stop.
|
|
Defaults to unlimited duration. Use 0 or negatives to disable.
|
|
|
|
```java
|
|
cameraView.setVideoMaxDuration(100000);
|
|
cameraView.setVideoMaxDuration(0); // Disable
|
|
```
|
|
|
|
##### cameraVideoBitRate
|
|
|
|
Controls the video bit rate in bits per second.
|
|
Use 0 or a negative value to fallback to the encoder default. Defaults to 0.
|
|
|
|
```java
|
|
cameraView.setVideoBitRate(0);
|
|
cameraView.setVideoBitRate(4000000);
|
|
```
|
|
|