Not able to run Gstreamer properly

When I try the following command, I see no error:
gst-launch-1.0 uridecodebin uri=file:/home/Desktop/videos/1.mkv ! nvvideoconvert ! nvv4l2vp8enc ! rtpvp8pay ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 ! appsink

but if I try to use the pipeline into OpenCV I am getting errors:
pipeline = “uridecodebin uri=file://home/Desktop/videos/1.mkv ! nvvideoconvert ! nvv4l2vp8enc ! rtpvp8pay ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 ! appsink”

vs = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)
while True:
ret, frame =
if ret:
cv2.imwrite(“frame.jpg”, frame)

[ WARN:0] global /home/Desktop/JEP/script/workspace/opencv-4.5.0/modules/videoio/src/cap_gstreamer.cpp (1761) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Resource not found.
[ WARN:0] global /home/Desktop/JEP/script/workspace/opencv-4.5.0/modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/Desktop/JEP/script/workspace/opencv-4.5.0/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
<VideoCapture 0x7fae6dbf50>
Traceback (most recent call last):
File “”, line 10, in
AttributeError: ‘NoneType’ object has no attribute ‘shape’

Hi @isaac-223 ,

We had a problem similar with your question before. We have upgraded OpenCV version to 4.1.1 and our problem was solved by doing that.

Best wishes.

1 Like

The problem is that opencv videoCapture from gstreamer doesn’t support VP8 format (list). Usually it receives BGR for color video, such as:

vs = cv2.VideoCapture("uridecodebin uri=file://home/Desktop/videos/1.mkv ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1", cv2.CAP_GSTREAMER)

You may explain what is your case for better help.

@ozguryildiz I have recently installed OpenCV, its the latest one.

@Honey_Patouceul I tried the line of code above as…
gst-launch-1.0 uridecodebin uri=file://home/Desktop/videos/1.mkv ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! format=BGR ! appsink drop=1

and got the following output:

(gst-launch-1.0:11429): GStreamer-CRITICAL **: 20:46:35.641: gst_element_link_pads_filtered: assertion ‘GST_IS_BIN (parent)’ failed
WARNING: erroneous pipeline: syntax error

I want to be able to read any video file and extract frames from it to further pass it for detection and inference.

Sorry there was a typo in my command. I’ve corrected it.

Be aware that in gst-launch appsink will do nothing and may allocate more and more memory until you kill it.

@Honey_Patouceul Thank you so much. it worked!
Do we have any other alternative than appsink which would help in capturing frames from any video stream and is memory efficient at a same time?

appsink is what you need for reading output of a pipeline from an application such as your one with opencv. My warning was just about using it in gst-launch command. From opencv application there should be no memory issue.
For using with gst-launch, fakesink (a pure sink that does nothing) would a better alternative.

1 Like

Alright! Thank you so much @Honey_Patouceul for your help and guidance I really appreciate that.