Disable setting profile/level for API level < 24.
We have seen devices running on API21/23 fail transcoding because of setting encoding profile/level. Some devices (ale-123/nexus 7) on API21 returns ENOSYS (Function not implemented) when being configured with a profile setting. (although API21 introduced the capability of setting encoding profile) Some devices (nexus 5) on API23 fails configuration with a specific parameter set, despite advertising support for it. Not setting the baseline profile has no effect on encoding, because when not set, the encoding will pick a suitable profile to use. Since baseline is the lowest possible profile, the auto-picked value can't be worse than baseline. Ref: b/218696352 PiperOrigin-RevId: 427792124
This commit is contained in:
parent
b9cb87153f
commit
ba3558c0c6
@ -176,7 +176,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
|
|||||||
// in-app muxing.
|
// in-app muxing.
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_LATENCY, 1);
|
mediaFormat.setInteger(MediaFormat.KEY_LATENCY, 1);
|
||||||
}
|
}
|
||||||
} else if (Util.SDK_INT >= 23) {
|
} else if (Util.SDK_INT >= 24) {
|
||||||
int supportedLevel =
|
int supportedLevel =
|
||||||
EncoderUtil.findHighestSupportedEncodingLevel(
|
EncoderUtil.findHighestSupportedEncodingLevel(
|
||||||
encoderInfo, mimeType, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
|
encoderInfo, mimeType, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
|
||||||
@ -186,12 +186,9 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
|
|||||||
mediaFormat.setInteger(
|
mediaFormat.setInteger(
|
||||||
MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
|
MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_LEVEL, supportedLevel);
|
mediaFormat.setInteger(MediaFormat.KEY_LEVEL, supportedLevel);
|
||||||
} else {
|
|
||||||
// Use the baseline profile for safest results, as encoding in baseline is required per
|
|
||||||
// https://source.android.com/compatibility/5.0/android-5.0-cdd#5_2_video_encoding
|
|
||||||
mediaFormat.setInteger(
|
|
||||||
MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
|
|
||||||
}
|
}
|
||||||
|
// For API levels below 24, setting profile and level can lead to failures in MediaCodec
|
||||||
|
// configuration. The encoder selects the profile/level when we don't set them.
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, DEFAULT_COLOR_FORMAT);
|
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, DEFAULT_COLOR_FORMAT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user