opencv
codec_error
ai_generated
true
OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27
ID: opencv/codec-not-found
82%Fix Rate
85%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4 | active | — | — | — |
| 4 | active | — | — | — |
Root Cause
VideoWriter cannot find the requested codec fourcc. Codec not installed or not compiled into FFmpeg backend.
genericWorkarounds
-
92% success Use a widely-supported codec fourcc
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # MPEG-4 is nearly universally available
Sources: https://docs.opencv.org/4.x/d0/d05/tutorial_dnn_googlenet.html
-
88% success Install FFmpeg with the required codec
sudo apt install ffmpeg libx264-dev && pip install --force-reinstall opencv-python
-
82% success Check available backends and codecs
print(cv2.getBuildInformation()) # check FFMPEG section for enabled codecs
Dead Ends
Common approaches that don't work:
-
Use raw/uncompressed fourcc to avoid codec issues
68% fail
Uncompressed video produces enormous files (1080p@30fps ~ 5.6 GB/min). Not a practical solution.
-
Install a random codec pack
80% fail
OpenCV uses its bundled FFmpeg or system FFmpeg. Random codec packs do not affect it.