{
  "id": "opencv/video-capture-frame-size-mismatch",
  "signature": "cv2.error: OpenCV(4.6.0) /tmp/opencv-4.6.0/modules/videoio/src/cap.cpp:293: error: (-215:Assertion failed) frame_size.width > 0 && frame_size.height > 0 in function 'CvCapture_FFMPEG::open'",
  "signature_zh": "cv2.error: OpenCV(4.6.0) /tmp/opencv-4.6.0/modules/videoio/src/cap.cpp:293: error: (-215:断言失败) frame_size.width > 0 && frame_size.height > 0 在函数 'CvCapture_FFMPEG::open' 中",
  "regex": "frame_size\\.width > 0 && frame_size\\.height > 0.*CvCapture_FFMPEG::open",
  "domain": "opencv",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Video file cannot be opened because the frame dimensions are zero or negative, often due to a corrupted file, unsupported codec, or missing codec library.",
  "root_cause_type": "generic",
  "root_cause_zh": "视频文件无法打开，因为帧尺寸为零或负数，通常是由于文件损坏、不支持的编解码器或缺少编解码器库。",
  "versions": [
    {
      "version": "4.5.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Changing the video file extension doesn't fix the underlying codec or corruption issue.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Setting CAP_PROP_FRAME_WIDTH/HEIGHT before opening won't help if the file itself has zero dimensions.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Reinstalling opencv-python doesn't add missing system codec libraries like libavcodec.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Verify the video file with ffprobe: `ffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 input.mp4`. If dimensions are 0x0, re-encode the video: `ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4`",
      "success_rate": 0.8,
      "how": "Verify the video file with ffprobe: `ffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 input.mp4`. If dimensions are 0x0, re-encode the video: `ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Install FFmpeg with full codec support: `sudo apt-get install ffmpeg libavcodec-extra` or `brew install ffmpeg` on macOS.",
      "success_rate": 0.75,
      "how": "Install FFmpeg with full codec support: `sudo apt-get install ffmpeg libavcodec-extra` or `brew install ffmpeg` on macOS.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Try a different video backend: `cap = cv2.VideoCapture('video.mp4', cv2.CAP_FFMPEG)` or `cap = cv2.VideoCapture('video.mp4', cv2.CAP_GSTREAMER)`",
      "success_rate": 0.7,
      "how": "Try a different video backend: `cap = cv2.VideoCapture('video.mp4', cv2.CAP_FFMPEG)` or `cap = cv2.VideoCapture('video.mp4', cv2.CAP_GSTREAMER)`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Verify the video file with ffprobe: `ffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 input.mp4`. If dimensions are 0x0, re-encode the video: `ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4`",
    "Install FFmpeg with full codec support: `sudo apt-get install ffmpeg libavcodec-extra` or `brew install ffmpeg` on macOS.",
    "Try a different video backend: `cap = cv2.VideoCapture('video.mp4', cv2.CAP_FFMPEG)` or `cap = cv2.VideoCapture('video.mp4', cv2.CAP_GSTREAMER)`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d8/dfe/classcv_1_1VideoCapture.html#a57c0e81e83e60f36c83027dc2a188e80",
  "official_doc_section": null,
  "error_code": "-215",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2023-03-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}