fix: Fix VideoProfile
possibly being null (#2231)
* fix: Fix `VideoProfile` possibly being null * Format
This commit is contained in:
parent
9df46670a8
commit
c23f49e6bd
@ -31,8 +31,11 @@ fun RecordingSession.getRecommendedBitRate(fps: Int, codec: VideoCodec, hdr: Boo
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val profiles = CamcorderProfile.getAll(cameraId, quality)
|
||||
if (profiles != null) {
|
||||
val best = profiles.videoProfiles.minBy { abs(it.width * it.height - targetResolution.width * targetResolution.height) }
|
||||
val best = profiles.videoProfiles.filterNotNull().minBy {
|
||||
abs(it.width * it.height - targetResolution.width * targetResolution.height)
|
||||
}
|
||||
|
||||
if (best != null) {
|
||||
recommendedProfile = RecommendedProfile(
|
||||
best.bitrate,
|
||||
best.codec,
|
||||
@ -41,6 +44,7 @@ fun RecordingSession.getRecommendedBitRate(fps: Int, codec: VideoCodec, hdr: Boo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recommendedProfile == null) {
|
||||
val cameraIdInt = cameraId.toIntOrNull()
|
||||
|
Loading…
Reference in New Issue
Block a user