0x80001001
android
runtime_error
ai_generated
true
android.media.MediaCodec$CodecException: 错误0x80001001: 配置编解码器失败(格式不受支持)
android.media.MediaCodec$CodecException: Error 0x80001001: Failed to configure codec (format not supported)
ID: android/mediacodec-format-not-supported
88%修复率
86%置信度
1证据数
2023-04-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Android 11 (API 30) | active | — | — | — |
| Android 12 (API 31) | active | — | — | — |
| Android 13 (API 33) | active | — | — | — |
| MediaCodec API (all versions) | active | — | — | — |
根因分析
使用包含设备硬件解码器/编码器不支持的参数(例如分辨率、比特率或配置文件)的MediaFormat调用MediaCodec.configure()。
English
MediaCodec.configure() is called with a MediaFormat containing unsupported parameters (e.g., resolution, bitrate, or profile) for the selected codec on the device's hardware decoder/encoder.
官方文档
https://developer.android.com/reference/android/media/MediaCodec#configure(android.media.MediaFormat,%20android.view.Surface,%20android.media.MediaCrypto,%20int)解决方案
-
Query codec capabilities using MediaCodecList.getCodecCapabilities() and adjust format parameters (e.g., reduce resolution, change profile). Example: val capabilities = MediaCodecList(MediaCodecList.REGULAR_CODECS).findEncoderForFormat(format); val codecInfo = MediaCodecList.getCodecInfoAt(index); val caps = codecInfo.getCapabilitiesForType(mimeType);
-
Fall back to a software codec by using MediaCodecList with a specific component name that is known to support the format, or use MediaCodec.createDecoderByType() with a fallback to MediaCodec.createByCodecName() using a software decoder name.
无效尝试
常见但无效的做法:
-
Hardcode a specific codec name like 'video/avc' without checking device support
80% 失败
Different devices support different profiles and levels within a codec. Hardcoding a codec name does not ensure the format parameters are valid.
-
Use the highest resolution supported by the camera sensor
75% 失败
The encoder may not support that resolution even if the camera does. The codec's capabilities are independent of the camera's.