-215
opencv
runtime_error
ai_generated
partial
cv2.error: OpenCV(4.8.0) /modules/videoio/src/cap_gstreamer.cpp:1058: error: (-215:断言失败) gst_pipeline 为空 在函数 'CvCapture_GStreamer::open' 中
cv2.error: OpenCV(4.8.0) /modules/videoio/src/cap_gstreamer.cpp:1058: error: (-215:Assertion failed) gst_pipeline is NULL in function 'CvCapture_GStreamer::open'
ID: opencv/video-capture-gstreamer-pipeline-failed
85%修复率
85%置信度
1证据数
2024-08-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.8.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
根因分析
传递给 VideoCapture 的 GStreamer 管道字符串无效,或 GStreamer 未正确初始化。
English
The GStreamer pipeline string passed to VideoCapture is invalid or GStreamer is not properly initialized.
官方文档
https://docs.opencv.org/4.x/dd/d43/tutorial_gstreamer.html解决方案
-
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) -
cap = cv2.VideoCapture('rtspsrc location=rtsp://example.com/stream ! decodebin ! videoconvert ! appsink', cv2.CAP_GSTREAMER)
无效尝试
常见但无效的做法:
-
40% 失败
If OpenCV is built without GStreamer backend, the error changes; this error specifically occurs when GStreamer is present but pipeline fails.
-
60% 失败
For RTSP or network streams, a file path won't work; the pipeline must be correctly formatted.
-
50% 失败
Missing plugins (e.g., 'videotestsrc') cause pipeline construction to fail silently; the error is not just about syntax.