# 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'

- **ID:** `opencv/video-capture-frame-size-mismatch`
- **Domain:** opencv
- **Category:** runtime_error
- **Error Code:** `-215`
- **Verification:** ai_generated
- **Fix Rate:** 75%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.5 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.0 | active | — | — |

## Workarounds

1. **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`** (80% success)
   ```
   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`
   ```
2. **Install FFmpeg with full codec support: `sudo apt-get install ffmpeg libavcodec-extra` or `brew install ffmpeg` on macOS.** (75% success)
   ```
   Install FFmpeg with full codec support: `sudo apt-get install ffmpeg libavcodec-extra` or `brew install ffmpeg` on macOS.
   ```
3. **Try a different video backend: `cap = cv2.VideoCapture('video.mp4', cv2.CAP_FFMPEG)` or `cap = cv2.VideoCapture('video.mp4', cv2.CAP_GSTREAMER)`** (70% success)
   ```
   Try a different video backend: `cap = cv2.VideoCapture('video.mp4', cv2.CAP_FFMPEG)` or `cap = cv2.VideoCapture('video.mp4', cv2.CAP_GSTREAMER)`
   ```

## Dead Ends

- **** — Changing the video file extension doesn't fix the underlying codec or corruption issue. (90% fail)
- **** — Setting CAP_PROP_FRAME_WIDTH/HEIGHT before opening won't help if the file itself has zero dimensions. (70% fail)
- **** — Reinstalling opencv-python doesn't add missing system codec libraries like libavcodec. (50% fail)
