Skip to content

Commit f1e98f0

Browse files
committed
Use the same bitrate formula as TimeLapse
1 parent 8e2cd15 commit f1e98f0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/java/com/dan/videostab/VideoEncoder.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ class VideoEncoder(
2828
private val BITRATE_REF_H264 = Range(3000000, 6000000)
2929
private val BITRATE_REF_H265 = Range(BITRATE_REF_H264.start / 2, BITRATE_REF_H264.end / 2)
3030

31-
private fun getBitRate(refValue: Int, refRange: Range, width: Int, height: Int, fps: Int): Int {
32-
val alpha = (width.toDouble() * height) / (1920.0 * 1080.0)
31+
private fun getBitRate(refValue: Int, refRange: Range, width: Int, height: Int, fps_: Int): Int {
32+
val fps = if (fps_ < 30) 30 else fps_
33+
val alpha = (width.toDouble() * height * fps) / (1920.0 * 1080.0 * 30)
3334
val range = Range( (refRange.start * alpha).toInt(), (refRange.end * alpha).toInt())
3435

3536
return when {

0 commit comments

Comments
 (0)