{
  "id": "opencv/videoio-camera-format-unsupported",
  "signature": "VIDEOIO ERROR: V4L2: Pixel format of stream 0 is not supported by OpenCV",
  "signature_zh": "VIDEOIO 错误：V4L2：流 0 的像素格式不受 OpenCV 支持",
  "regex": "VIDEOIO ERROR.*V4L2.*Pixel format.*not supported",
  "domain": "opencv",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The camera provides a pixel format (e.g., MJPG, YUYV, NV12) that OpenCV's V4L2 backend cannot decode directly without conversion.",
  "root_cause_type": "generic",
  "root_cause_zh": "摄像头提供的像素格式（例如 MJPG、YUYV、NV12）OpenCV 的 V4L2 后端无法直接解码，需要转换。",
  "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.1",
      "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": "Installing v4l-utils and running v4l2-ctl to change format without restarting the app",
      "why_fails": "The format change is not picked up by an already-opened VideoCapture; need to reopen.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting CAP_PROP_FOURCC to 'MJPG' after opening camera",
      "why_fails": "The property must be set before opening the camera or on a closed capture.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Recompiling OpenCV with different V4L2 flags but not rebuilding the app",
      "why_fails": "The app links against the old library; a full rebuild is needed.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Before opening the camera, set the desired pixel format using CAP_PROP_FOURCC: cap = cv2.VideoCapture(0); cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M','J','P','G'))",
      "success_rate": 0.85,
      "how": "Before opening the camera, set the desired pixel format using CAP_PROP_FOURCC: cap = cv2.VideoCapture(0); cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M','J','P','G'))",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use the GStreamer backend instead: cap = cv2.VideoCapture('v4l2src ! videoconvert ! appsink', cv2.CAP_GSTREAMER)",
      "success_rate": 0.78,
      "how": "Use the GStreamer backend instead: cap = cv2.VideoCapture('v4l2src ! videoconvert ! appsink', cv2.CAP_GSTREAMER)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Before opening the camera, set the desired pixel format using CAP_PROP_FOURCC: cap = cv2.VideoCapture(0); cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M','J','P','G'))",
    "Use the GStreamer backend instead: cap = cv2.VideoCapture('v4l2src ! videoconvert ! appsink', cv2.CAP_GSTREAMER)"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/dd/d43/tutorial_py_video_display.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.82,
  "resolvable": "partial",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}