Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,26 @@ public int getVideoBitRate() {
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)}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static class Stub {
public int maxDuration;
public int endReason;
public int videoBitRate;
public double videoCaptureRate;
public int videoFrameRate;
public int audioBitRate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -245,6 +246,16 @@ public final int getVideoBitRate() {
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;
Expand Down Expand Up @@ -601,6 +612,7 @@ public void run() {
stub.maxSize = mVideoMaxSize;
stub.maxDuration = mVideoMaxDuration;
stub.videoBitRate = mVideoBitRate;
stub.videoCaptureRate = mVideoCaptureRate;
stub.audioBitRate = mAudioBitRate;
onTakeVideo(stub);
}
Expand All @@ -626,6 +638,7 @@ public void run() {
stub.location = mLocation;
stub.facing = mFacing;
stub.videoBitRate = mVideoBitRate;
stub.videoCaptureRate = mVideoCaptureRate;
stub.audioBitRate = mAudioBitRate;
stub.audio = mAudio;
stub.maxSize = mVideoMaxSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ public final void onSurfaceDestroyed() {
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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ private boolean prepareMediaRecorder(@NonNull VideoResult.Stub stub,
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);

Expand Down