fix: Fix VideoProfile
possibly being null (#2231)
* fix: Fix `VideoProfile` possibly being null * Format
This commit is contained in:
parent
9df46670a8
commit
c23f49e6bd
@ -31,14 +31,18 @@ fun RecordingSession.getRecommendedBitRate(fps: Int, codec: VideoCodec, hdr: Boo
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
val profiles = CamcorderProfile.getAll(cameraId, quality)
|
val profiles = CamcorderProfile.getAll(cameraId, quality)
|
||||||
if (profiles != null) {
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
recommendedProfile = RecommendedProfile(
|
if (best != null) {
|
||||||
best.bitrate,
|
recommendedProfile = RecommendedProfile(
|
||||||
best.codec,
|
best.bitrate,
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) best.bitDepth else 8,
|
best.codec,
|
||||||
best.frameRate
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) best.bitDepth else 8,
|
||||||
)
|
best.frameRate
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user