# android.media.MediaCodec$CodecException: 错误0x80001001: 配置编解码器失败（格式不受支持）

- **ID:** `android/mediacodec-format-not-supported`
- **领域:** android
- **类别:** runtime_error
- **错误码:** `0x80001001`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

使用包含设备硬件解码器/编码器不支持的参数（例如分辨率、比特率或配置文件）的MediaFormat调用MediaCodec.configure()。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Android 11 (API 30) | active | — | — |
| Android 12 (API 31) | active | — | — |
| Android 13 (API 33) | active | — | — |
| MediaCodec API (all versions) | active | — | — |

## 解决方案

1. ```
   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);
   ```
2. ```
   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** — Different devices support different profiles and levels within a codec. Hardcoding a codec name does not ensure the format parameters are valid. (80% 失败率)
- **Use the highest resolution supported by the camera sensor** — The encoder may not support that resolution even if the camera does. The codec's capabilities are independent of the camera's. (75% 失败率)
