opencv
encoding_error
ai_generated
partial
OpenCV: FFMPEG: 标签 0x3234504d/'MP42' 不受代码 ID 12 支持
OpenCV: FFMPEG: tag 0x3234504d/'MP42' is not supported with codec id 12
ID: opencv/videowriter-codec-not-supported-linux
70%修复率
80%置信度
1证据数
2023-05-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.5.0 | active | — | — | — |
| 4.6.0 | active | — | — | — |
| 4.7.0 | active | — | — | — |
| 4.8.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
根因分析
指定的视频编解码器 (MP42) 不被当前系统上的 FFMPEG 后端支持,通常是因为缺少编解码器库或 FFMPEG 构建不兼容。
English
The specified video codec (MP42) is not supported by the FFMPEG backend on the current system, often due to missing codec libraries or incompatible FFMPEG build.
官方文档
https://docs.opencv.org/4.x/dd/d9e/classcv_1_1VideoWriter.html解决方案
-
Use a widely supported codec like 'avc1' or 'H264' with FFMPEG: `fourcc = cv2.VideoWriter_fourcc(*'avc1')` and verify with `cv2.VideoWriter.isOpened()`.
-
Install the necessary codec libraries: `sudo apt-get install libavcodec-extra` on Ubuntu/Debian or `brew install ffmpeg` on macOS.
-
Fall back to a raw video codec like 'I420' (uncompressed) for debugging: `fourcc = cv2.VideoWriter_fourcc(*'I420')`.
无效尝试
常见但无效的做法:
-
75% 失败
The codec is still MP42, which may not be supported regardless of container format.
-
85% 失败
Without FFMPEG, OpenCV uses a different backend (e.g., VFW on Windows) which may have its own limitations.
-
65% 失败
XVID might also be unsupported if the codec is not installed; the fix is to use a codec known to work on the system.