Skip to content

Commit 4fea4bb

Browse files
committed
Add test on calculateOptimalBitrate
1 parent ed7a36e commit 4fea4bb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libraries/androidutils/src/test/kotlin/io/element/android/libraries/androidutils/media/VideoCompressorHelperTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,16 @@ class VideoCompressorHelperTest {
6464
outputSize = helper.getOutputSize(inputSize)
6565
assertThat(outputSize).isEqualTo(Size(480, 640))
6666
}
67+
68+
@Test
69+
fun `test calculateOptimalBitrate`() {
70+
val helper = VideoCompressorHelper(maxSize = 720)
71+
val inputSize = Size(1920, 1080)
72+
var bitrate = helper.calculateOptimalBitrate(inputSize, frameRate = 30)
73+
// Output size will be 720x405, so bitrate = 720*405*0.1*30 = 874800
74+
assertThat(bitrate).isEqualTo(874800L)
75+
// Half frame rate, half bitrate
76+
bitrate = helper.calculateOptimalBitrate(inputSize, frameRate = 15)
77+
assertThat(bitrate).isEqualTo(437400L)
78+
}
6779
}

0 commit comments

Comments
 (0)