Do the same for video frame rate

pull/545/head
Mattia Iavarone 6 years ago
parent 6fb2c41eb2
commit 2c343290f8
  1. 17
      cameraview/src/main/java/com/otaliastudios/cameraview/internal/DeviceEncoders.java
  2. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/video/SnapshotVideoRecorder.java

@ -170,6 +170,23 @@ public class DeviceEncoders {
return newBitRate; return newBitRate;
} }
/**
* Returns a video frame rate supported by the device encoders.
* This means adjusting the input frame rate if needed, to match encoder constraints.
*
* @param frameRate input rate
* @return adjusted rate
*/
@SuppressLint("NewApi")
public int getSupportedVideoFrameRate(@NonNull Size size, int frameRate) {
if (!mEnabled) return frameRate;
int newFrameRate = (int) (double) mVideoCapabilities
.getSupportedFrameRatesFor(size.getWidth(), size.getHeight())
.clamp((double) frameRate);
LOG.i("getSupportedVideoFrameRate -", "inputRate:", frameRate, "adjustedRate:", newFrameRate);
return newFrameRate;
}
/** /**
* Returns an audio bit rate supported by the device encoders. * Returns an audio bit rate supported by the device encoders.
* This means adjusting the input bit rate if needed, to match encoder constraints. * This means adjusting the input bit rate if needed, to match encoder constraints.

@ -136,6 +136,7 @@ public class SnapshotVideoRecorder extends VideoRecorder implements RendererFram
mResult.size = deviceEncoders.getSupportedVideoSize(mResult.size); mResult.size = deviceEncoders.getSupportedVideoSize(mResult.size);
mResult.videoBitRate = deviceEncoders.getSupportedVideoBitRate(mResult.videoBitRate); mResult.videoBitRate = deviceEncoders.getSupportedVideoBitRate(mResult.videoBitRate);
mResult.audioBitRate = deviceEncoders.getSupportedAudioBitRate(mResult.audioBitRate); mResult.audioBitRate = deviceEncoders.getSupportedAudioBitRate(mResult.audioBitRate);
mResult.videoFrameRate = deviceEncoders.getSupportedVideoFrameRate(mResult.size, mResult.videoFrameRate);
// Video // Video
TextureConfig videoConfig = new TextureConfig(); TextureConfig videoConfig = new TextureConfig();

Loading…
Cancel
Save