opencv
encoding_error
ai_generated
partial
OpenCV: FFMPEG: 标签0x5634504d/'MP4V'不支持编解码器id 12
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12
ID: opencv/video-writer-fourcc-codec-not-supported
75%修复率
87%置信度
1证据数
2024-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.6.0 | active | — | — | — |
| 4.8.1 | active | — | — | — |
根因分析
指定的VideoWriter FOURCC码在当前系统上不受FFMPEG后端支持,通常由于缺少编解码器或容器格式不兼容。
English
The specified FOURCC code for VideoWriter is not supported by the FFMPEG backend on the current system, often due to missing codec or incompatible container format.
官方文档
https://docs.opencv.org/4.x/dd/d9e/classcv_1_1VideoWriter.html#a1b3b7b3e3e3e3e3e3e3e3e3e3e3e3e3解决方案
-
使用广泛支持的编解码器,如'avc1'(H.264)配合.mp4容器,或'MJPG'配合.avi容器。通过ffmpeg -encoders | grep h264验证编解码器可用性。
-
通过使用cv2.CAP_OPENCV_MJPEG或指定apiPreference参数,将VideoWriter后端切换到OpenCV内置编解码器。
无效尝试
常见但无效的做法:
-
Changing FOURCC to 'XVID' without checking container compatibility
60% 失败
XVID codec may not be installed or may require AVI container; using MP4 container fails.
-
Reinstalling OpenCV with different flags but not installing ffmpeg codecs
50% 失败
Codec support depends on system ffmpeg libraries, not OpenCV build flags alone.