-215 opencv config_error ai_generated true

cv2.error: OpenCV(4.5.5) /modules/videoio/src/cap_gstreamer.cpp:1156: error: (-215:Assertion failed) !pipeline.empty() in function 'open'

ID: opencv/gstreamer-pipeline-string-error

Also available as: JSON · Markdown · 中文
88%Fix Rate
82%Confidence
1Evidence
2023-03-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
4.5.5 active
4.6.0 active
4.7.0 active

Root Cause

GStreamer pipeline string passed to VideoCapture is empty or malformed, causing the pipeline to fail to initialize.

generic

中文

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

Official Documentation

https://docs.opencv.org/4.5.5/d4/d15/group__videoio__flags__gstreamer.html

Workarounds

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

中文步骤

  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.

Dead Ends

Common approaches that don't work:

  1. Adding quotation marks around the pipeline string in Python. 50% fail

    Adding extra spaces or quotes around the pipeline string does not fix the underlying syntax; GStreamer expects exact format.

  2. Passing a video file path without the 'filesrc location=' prefix. 80% fail

    Using a file path instead of a pipeline string still triggers the assertion because the pipeline is empty.

  3. Reinstalling GStreamer from source without checking pipeline syntax. 40% fail

    Installing a different GStreamer version may break syntax compatibility.