From 905d2ab432139269e6b0c4e598cf667f08d1a503 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 16 Feb 2019 11:40:48 +0100 Subject: [PATCH] explicitly set profile+level for encoder some modern Androids (namely my Xiaomi Mi A1 after the update to Andorid 9) seem to require that --- .../siacs/conversations/utils/Android360pFormatStrategy.java | 5 ++++- .../siacs/conversations/utils/Android720pFormatStrategy.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java b/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java index 4215a2611..761eff2a3 100644 --- a/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java +++ b/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java @@ -53,11 +53,14 @@ public class Android360pFormatStrategy implements MediaFormatStrategy { return null; } MediaFormat format = MediaFormat.createVideoFormat("video/avc", outWidth, outHeight); - // From Nexus 4 Camera in 720p format.setInteger(MediaFormat.KEY_BIT_RATE, mVideoBitrate); format.setInteger(MediaFormat.KEY_FRAME_RATE, 30); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 3); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + format.setInteger(MediaFormat.KEY_PROFILE ,MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline); + format.setInteger(MediaFormat.KEY_LEVEL, MediaCodecInfo.CodecProfileLevel.AVCLevel13); + } return format; } diff --git a/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java b/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java index e54b078de..981866951 100644 --- a/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java +++ b/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java @@ -53,11 +53,14 @@ public class Android720pFormatStrategy implements MediaFormatStrategy { return null; } MediaFormat format = MediaFormat.createVideoFormat("video/avc", outWidth, outHeight); - // From Nexus 4 Camera in 720p format.setInteger(MediaFormat.KEY_BIT_RATE, mVideoBitrate); format.setInteger(MediaFormat.KEY_FRAME_RATE, 30); format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 3); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + format.setInteger(MediaFormat.KEY_PROFILE ,MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline); + format.setInteger(MediaFormat.KEY_LEVEL, MediaCodecInfo.CodecProfileLevel.AVCLevel13); + } return format; }