opencv
encoding_error
ai_generated
partial
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12
ID: opencv/video-writer-fourcc-codec-not-supported
75%Fix Rate
87%Confidence
1Evidence
2024-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.6.0 | active | — | — | — |
| 4.8.1 | active | — | — | — |
Root Cause
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.
generic中文
指定的VideoWriter FOURCC码在当前系统上不受FFMPEG后端支持,通常由于缺少编解码器或容器格式不兼容。
Official Documentation
https://docs.opencv.org/4.x/dd/d9e/classcv_1_1VideoWriter.html#a1b3b7b3e3e3e3e3e3e3e3e3e3e3e3e3Workarounds
-
85% success Use a widely supported codec like 'avc1' (H.264) with .mp4 container, or 'MJPG' with .avi container. Verify codec availability with: ffmpeg -encoders | grep h264
Use a widely supported codec like 'avc1' (H.264) with .mp4 container, or 'MJPG' with .avi container. Verify codec availability with: ffmpeg -encoders | grep h264
-
70% success Switch VideoWriter backend to OpenCV's built-in codecs by using cv2.CAP_OPENCV_MJPEG or specify backend via cv2.VideoWriter(filename, apiPreference, fourcc, ...).
Switch VideoWriter backend to OpenCV's built-in codecs by using cv2.CAP_OPENCV_MJPEG or specify backend via cv2.VideoWriter(filename, apiPreference, fourcc, ...).
中文步骤
使用广泛支持的编解码器,如'avc1'(H.264)配合.mp4容器,或'MJPG'配合.avi容器。通过ffmpeg -encoders | grep h264验证编解码器可用性。
通过使用cv2.CAP_OPENCV_MJPEG或指定apiPreference参数,将VideoWriter后端切换到OpenCV内置编解码器。
Dead Ends
Common approaches that don't work:
-
Changing FOURCC to 'XVID' without checking container compatibility
60% fail
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% fail
Codec support depends on system ffmpeg libraries, not OpenCV build flags alone.