# cv2.error: OpenCV(4.8.0) /modules/videoio/src/cap_gstreamer.cpp:1058: error: (-215:断言失败) gst_pipeline 为空 在函数 'CvCapture_GStreamer::open' 中

- **ID:** `opencv/video-capture-gstreamer-pipeline-failed`
- **领域:** opencv
- **类别:** runtime_error
- **错误码:** `-215`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

传递给 VideoCapture 的 GStreamer 管道字符串无效，或 GStreamer 未正确初始化。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.5.5 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## 解决方案

1. ```
   gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
# If this works, adapt the same pipeline string for OpenCV:
cap = cv2.VideoCapture('videotestsrc ! videoconvert ! appsink', cv2.CAP_GSTREAMER)
   ```
2. ```
   cap = cv2.VideoCapture('rtspsrc location=rtsp://example.com/stream ! decodebin ! videoconvert ! appsink', cv2.CAP_GSTREAMER)
   ```

## 无效尝试

- **** — If OpenCV is built without GStreamer backend, the error changes; this error specifically occurs when GStreamer is present but pipeline fails. (40% 失败率)
- **** — For RTSP or network streams, a file path won't work; the pipeline must be correctly formatted. (60% 失败率)
- **** — Missing plugins (e.g., 'videotestsrc') cause pipeline construction to fail silently; the error is not just about syntax. (50% 失败率)
