Created
March 24, 2022 16:01
-
-
Save dturner/4fd1810b133e609916511a99d4fcd114 to your computer and use it in GitHub Desktop.
Example of using performance class to determine video encoding settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OptimalVideoSettings(context: Context){ | |
private val devicePerf: DevicePerformance = DevicePerformance.create(context) | |
val encodeHeight by lazy { | |
when (devicePerf.mediaPerformanceClass) { | |
Build.VERSION_CODES.S -> 1080 // On performance class 12 use 1080p | |
Build.VERSION_CODES.R -> 720 // On performance class 11 use 720p | |
else -> 480 | |
} | |
} | |
val encodeFps by lazy { | |
when(devicePerf.mediaPerformanceClass){ | |
Build.VERSION_CODES.S -> 60 // On performance class 12 use 60 fps | |
Build.VERSION_CODES.R -> 30 // On performance class 11 use 30 fps | |
else -> 30 | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment