# OpenCV: FFMPEG: 标签 0x3234504d/'MP42' 不受代码 ID 12 支持

- **ID:** `opencv/videowriter-codec-not-supported-linux`
- **领域:** opencv
- **类别:** encoding_error
- **验证级别:** ai_generated
- **修复率:** 70%

## 根因

指定的视频编解码器 (MP42) 不被当前系统上的 FFMPEG 后端支持，通常是因为缺少编解码器库或 FFMPEG 构建不兼容。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.5.0 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## 解决方案

1. ```
   Use a widely supported codec like 'avc1' or 'H264' with FFMPEG: `fourcc = cv2.VideoWriter_fourcc(*'avc1')` and verify with `cv2.VideoWriter.isOpened()`.
   ```
2. ```
   Install the necessary codec libraries: `sudo apt-get install libavcodec-extra` on Ubuntu/Debian or `brew install ffmpeg` on macOS.
   ```
3. ```
   Fall back to a raw video codec like 'I420' (uncompressed) for debugging: `fourcc = cv2.VideoWriter_fourcc(*'I420')`.
   ```

## 无效尝试

- **** — The codec is still MP42, which may not be supported regardless of container format. (75% 失败率)
- **** — Without FFMPEG, OpenCV uses a different backend (e.g., VFW on Windows) which may have its own limitations. (85% 失败率)
- **** — XVID might also be unsupported if the codec is not installed; the fix is to use a codec known to work on the system. (65% 失败率)
