# cv2.error: OpenCV(4.5.5) /modules/videoio/src/cap_gstreamer.cpp:1156: error: (-215:断言失败) !pipeline.empty() 在函数'open'中

- **ID:** `opencv/gstreamer-pipeline-string-error`
- **领域:** opencv
- **类别:** config_error
- **错误码:** `-215`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

传递给VideoCapture的GStreamer管道字符串为空或格式错误，导致管道初始化失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.5.5 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |

## 解决方案

1. ```
   Ensure the pipeline string is non-empty and correctly formatted, e.g., `cap = cv2.VideoCapture('videotestsrc ! appsink')`
   ```
2. ```
   Test the pipeline with `gst-launch-1.0` command line before using it in OpenCV to verify syntax.
   ```
3. ```
   If using a camera, use `cap = cv2.VideoCapture(0)` instead of a pipeline string to avoid this error.
   ```

## 无效尝试

- **Adding quotation marks around the pipeline string in Python.** — Adding extra spaces or quotes around the pipeline string does not fix the underlying syntax; GStreamer expects exact format. (50% 失败率)
- **Passing a video file path without the 'filesrc location=' prefix.** — Using a file path instead of a pipeline string still triggers the assertion because the pipeline is empty. (80% 失败率)
- **Reinstalling GStreamer from source without checking pipeline syntax.** — Installing a different GStreamer version may break syntax compatibility. (40% 失败率)
