{
  "id": "opencv/video-writer-codec-not-found",
  "signature": "cv2.error: OpenCV(4.8.0) /modules/videoio/src/cap_images.cpp: error: (-2:Unspecified error) could not find encoder for codec 0x47504A4D",
  "signature_zh": "cv2.error: OpenCV(4.8.0) /modules/videoio/src/cap_images.cpp: 错误: (-2:未指定错误) 找不到编码器用于编解码器 0x47504A4D",
  "regex": "could not find encoder for codec 0x[0-9A-F]+",
  "domain": "opencv",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The specified codec (e.g., MJPG, H264) is not supported by the installed FFmpeg or encoder backend on the system.",
  "root_cause_type": "generic",
  "root_cause_zh": "指定的编解码器（例如 MJPG、H264）不被系统上安装的 FFmpeg 或编码器后端支持。",
  "versions": [
    {
      "version": "4.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reinstall OpenCV with --with-ffmpeg flag",
      "why_fails": "The issue is not build-time but runtime; FFmpeg may be installed but the specific codec might be missing or disabled in the FFmpeg build.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "Change codec ID to a random fourcc code",
      "why_fails": "Random codecs are even less likely to be supported; must use a codec known to work with the installed FFmpeg.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use .avi extension instead of .mp4",
      "why_fails": "The extension does not determine the codec; the fourcc code must match a supported encoder.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "List available encoders with 'ffmpeg -encoders' and use a codec that appears in the list. Common working codecs: 'mp4v' (for MP4), 'XVID' (for AVI), 'MJPG' for motion JPEG.",
      "success_rate": 0.8,
      "how": "List available encoders with 'ffmpeg -encoders' and use a codec that appears in the list. Common working codecs: 'mp4v' (for MP4), 'XVID' (for AVI), 'MJPG' for motion JPEG.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Install a more complete FFmpeg build (e.g., from conda-forge or compile with --enable-libx264) to add missing codecs.",
      "success_rate": 0.7,
      "how": "Install a more complete FFmpeg build (e.g., from conda-forge or compile with --enable-libx264) to add missing codecs.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "List available encoders with 'ffmpeg -encoders' and use a codec that appears in the list. Common working codecs: 'mp4v' (for MP4), 'XVID' (for AVI), 'MJPG' for motion JPEG.",
    "Install a more complete FFmpeg build (e.g., from conda-forge or compile with --enable-libx264) to add missing codecs."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/dd/d9e/classcv_1_1VideoWriter.html",
  "official_doc_section": null,
  "error_code": "-2",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}