Add setter method for capture rate, can be used to record timelapse video

pull/890/head
Mohamed Hamdan 4 years ago
parent 4364ec7c3a
commit e6d8a74b30
  1. 20
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  2. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/VideoResult.java
  3. 13
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraBaseEngine.java
  4. 3
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java
  5. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/video/FullVideoRecorder.java

@ -1575,6 +1575,26 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
return mCameraEngine.getVideoBitRate();
}
/**
* Sets the capture rate in frame per second for video capturing.
* it's can used to capture timelapse video
* Will be used by {@link #takeVideo(File)}.
*
* @param captureRate desired capture rate
*/
public void setVideoCaptureRate(double captureRate) {
mCameraEngine.setVideoCaptureRate(captureRate);
}
/**
* Returns the current video bit rate.
* @return current bit rate
*/
@SuppressWarnings("unused")
public double getVideoCaptureRate() {
return mCameraEngine.getVideoCaptureRate();
}
/**
* A flag to control the behavior when calling {@link #setPreviewFrameRate(float)}.
*

@ -41,6 +41,7 @@ public class VideoResult {
public int maxDuration;
public int endReason;
public int videoBitRate;
public double videoCaptureRate;
public int videoFrameRate;
public int audioBitRate;
}

@ -85,6 +85,7 @@ public abstract class CameraBaseEngine extends CameraEngine {
private long mVideoMaxSize;
private int mVideoMaxDuration;
private int mVideoBitRate;
private double mVideoCaptureRate;
private int mAudioBitRate;
private long mAutoFocusResetDelayMillis;
private int mSnapshotMaxWidth; // in REF_VIEW like SizeSelectors
@ -245,6 +246,16 @@ public abstract class CameraBaseEngine extends CameraEngine {
return mVideoBitRate;
}
@Override
public final void setVideoCaptureRate(double videoCaptureRate) {
mVideoCaptureRate = videoCaptureRate;
}
@Override
public final double getVideoCaptureRate() {
return mVideoCaptureRate;
}
@Override
public final void setAudioCodec(@NonNull AudioCodec codec) {
mAudioCodec = codec;
@ -601,6 +612,7 @@ public abstract class CameraBaseEngine extends CameraEngine {
stub.maxSize = mVideoMaxSize;
stub.maxDuration = mVideoMaxDuration;
stub.videoBitRate = mVideoBitRate;
stub.videoCaptureRate = mVideoCaptureRate;
stub.audioBitRate = mAudioBitRate;
onTakeVideo(stub);
}
@ -626,6 +638,7 @@ public abstract class CameraBaseEngine extends CameraEngine {
stub.location = mLocation;
stub.facing = mFacing;
stub.videoBitRate = mVideoBitRate;
stub.videoCaptureRate = mVideoCaptureRate;
stub.audioBitRate = mAudioBitRate;
stub.audio = mAudio;
stub.maxSize = mVideoMaxSize;

@ -635,6 +635,9 @@ public abstract class CameraEngine implements
public abstract void setVideoBitRate(int videoBitRate);
public abstract int getVideoBitRate();
public abstract void setVideoCaptureRate(double videoCaptureRate);
public abstract double getVideoCaptureRate();
public abstract void setAudioBitRate(int audioBitRate);
public abstract int getAudioBitRate();

@ -215,6 +215,7 @@ public abstract class FullVideoRecorder extends VideoRecorder {
flip ? stub.size.getHeight() : stub.size.getWidth(),
flip ? stub.size.getWidth() : stub.size.getHeight());
mMediaRecorder.setVideoFrameRate(stub.videoFrameRate);
mMediaRecorder.setCaptureRate(stub.videoCaptureRate);
mMediaRecorder.setVideoEncoder(mProfile.videoCodec);
mMediaRecorder.setVideoEncodingBitRate(stub.videoBitRate);

Loading…
Cancel
Save