Skip to content

Instantly share code, notes, and snippets.

@dturner
Created March 24, 2022 16:01
Show Gist options
  • Save dturner/4fd1810b133e609916511a99d4fcd114 to your computer and use it in GitHub Desktop.
Save dturner/4fd1810b133e609916511a99d4fcd114 to your computer and use it in GitHub Desktop.
Example of using performance class to determine video encoding settings
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