Use variable bitrate mode when transcoding to ensure compatibility with old devices (#5223)

* Use variable bitrate mode when transcoding

This should be compatible with more devices that may lack the needed codecs to properly encode using constant bitrate mode (CBR).

* Fix video output size (again)
This commit is contained in:
Jorge Martin Espinosa 2025-08-26 10:41:07 +02:00 committed by GitHub
parent 9cd7c0ce49
commit 8c1c0b63bd
3 changed files with 11 additions and 12 deletions

View file

@ -27,7 +27,11 @@ class VideoCompressorHelper(
fun getOutputSize(inputSize: Size): Size {
val resultMajor = min(inputSize.major(), maxSize)
val aspectRatio = inputSize.major().toFloat() / inputSize.minor().toFloat()
return Size(resultMajor, (resultMajor / aspectRatio).roundToInt())
return if (inputSize.width >= inputSize.height) {
Size(resultMajor, (resultMajor / aspectRatio).roundToInt())
} else {
Size((resultMajor / aspectRatio).roundToInt(), resultMajor)
}
}
/**